ActivationContext Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Identifies the activation context for the current application. This class cannot be inherited.
public ref class ActivationContext sealed : IDisposable, System::Runtime::Serialization::ISerializable
[System.Runtime.InteropServices.ComVisible(false)]
[System.Serializable]
public sealed class ActivationContext : IDisposable, System.Runtime.Serialization.ISerializable
[<System.Runtime.InteropServices.ComVisible(false)>]
[<System.Serializable>]
type ActivationContext = class
interface IDisposable
interface ISerializable
Public NotInheritable Class ActivationContext
Implements IDisposable, ISerializable
- Inheritance
-
ActivationContext
- Attributes
- Implements
Examples
The following code example demonstrates the use of an ActivationContext object to obtain the ApplicationIdentity for a manifest-based application. For correct results, execute this code example as a manifest-based application.
using System;
namespace ActivationContextSample
{
public class Program : MarshalByRefObject
{
public static void Main(string[] args)
{
ActivationContext ac = AppDomain.CurrentDomain.ActivationContext;
ApplicationIdentity ai = ac.Identity;
Console.WriteLine("Full name = " + ai.FullName);
Console.WriteLine("Code base = " + ai.CodeBase);
Console.Read();
}
public void Run()
{
Main(new string[] { });
Console.ReadLine();
}
}
}
Imports System.Collections
Imports System.Text
Imports System.Security.Policy
Imports System.Reflection
Imports System.Security
Imports System.Security.Permissions
Public Class Program
Inherits MarshalByRefObject
<SecurityPermission(SecurityAction.LinkDemand, ControlDomainPolicy:=True)> _
Public Shared Sub Main(ByVal args() As String)
Dim ac As ActivationContext = AppDomain.CurrentDomain.ActivationContext
Dim ai As ApplicationIdentity = ac.Identity
Console.WriteLine("Full name = " + ai.FullName)
Console.WriteLine("Code base = " + ai.CodeBase)
Console.Read()
End Sub
<SecurityPermission(SecurityAction.LinkDemand, ControlDomainPolicy:=True)> _
Public Sub Run()
Main(New String() {})
Console.ReadLine()
End Sub
End Class
Remarks
The ActivationContext class contains an ApplicationIdentity and provides internal-only access to the application manifest. The activation context is used during manifest-based activation to set up the domain policy and provide an application-based security model. For more information, see the ApplicationSecurityManager class.
Important
This type implements the IDisposable interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its Dispose method in a try
/catch
block. To dispose of it indirectly, use a language construct such as using
(in C#) or Using
(in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the IDisposable interface topic.
Properties
ApplicationManifestBytes |
Gets the ClickOnce application manifest for the current application. |
DeploymentManifestBytes |
Gets the ClickOnce deployment manifest for the current application. |
Form |
Gets the form, or store context, for the current application. |
Identity |
Gets the application identity for the current application. |
Methods
CreatePartialActivationContext(ApplicationIdentity) |
Initializes a new instance of the ActivationContext class using the specified application identity. |
CreatePartialActivationContext(ApplicationIdentity, String[]) |
Initializes a new instance of the ActivationContext class using the specified application identity and array of manifest paths. |
Dispose() |
Releases all resources used by the ActivationContext. |
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
Finalize() |
Enables an ActivationContext object to attempt to free resources and perform other cleanup operations before the ActivationContext is reclaimed by garbage collection. |
GetHashCode() |
Serves as the default hash function. (Inherited from Object) |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
ToString() |
Returns a string that represents the current object. (Inherited from Object) |
Explicit Interface Implementations
ISerializable.GetObjectData(SerializationInfo, StreamingContext) |
Populates a SerializationInfo with the data needed to serialize the target object. |