ActivationContext ActivationContext ActivationContext ActivationContext Class

Definition

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)]
[Serializable]
public sealed class ActivationContext : IDisposable, System.Runtime.Serialization.ISerializable
type ActivationContext = class
    interface IDisposable
    interface ISerializable
Public NotInheritable Class ActivationContext
Implements IDisposable, ISerializable
Inheritance
ActivationContextActivationContextActivationContextActivationContext
Attributes
ComVisibleAttribute SerializableAttribute
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;
using System.Collections;
using System.Text;
using System.Security.Policy;
using System.Reflection;
using System.Security;
using System.Security.Permissions;

namespace ActivationContextSample
{
    public class Program : MarshalByRefObject
    {
        [SecurityPermission(SecurityAction.LinkDemand, ControlDomainPolicy=true)]
        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();
        }
        [SecurityPermission(SecurityAction.LinkDemand, ControlDomainPolicy=true)]
        public void Run()
        {
            Main(new string[] { });
            Console.ReadLine();
        }
    }
}
Imports System
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 'Main

    <SecurityPermission(SecurityAction.LinkDemand, ControlDomainPolicy:=True)> _
    Public Sub Run() 
        Main(New String() {})
        Console.ReadLine()
    
    End Sub 'Run
End Class 'Program

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 ApplicationManifestBytes ApplicationManifestBytes ApplicationManifestBytes

Gets the ClickOnce application manifest for the current application.

DeploymentManifestBytes DeploymentManifestBytes DeploymentManifestBytes DeploymentManifestBytes

Gets the ClickOnce deployment manifest for the current application.

Form Form Form Form

Gets the form, or store context, for the current application.

Identity Identity Identity Identity

Gets the application identity for the current application.

Methods

CreatePartialActivationContext(ApplicationIdentity) CreatePartialActivationContext(ApplicationIdentity) CreatePartialActivationContext(ApplicationIdentity) CreatePartialActivationContext(ApplicationIdentity)

Initializes a new instance of the ActivationContext class using the specified application identity.

CreatePartialActivationContext(ApplicationIdentity, String[]) CreatePartialActivationContext(ApplicationIdentity, String[]) CreatePartialActivationContext(ApplicationIdentity, String[]) CreatePartialActivationContext(ApplicationIdentity, String[])

Initializes a new instance of the ActivationContext class using the specified application identity and array of manifest paths.

Dispose() Dispose() Dispose() Dispose()

Releases all resources used by the ActivationContext.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
Finalize() Finalize() Finalize() Finalize()

Enables an ActivationContext object to attempt to free resources and perform other cleanup operations before the ActivationContext is reclaimed by garbage collection.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext)

Populates a SerializationInfo with the data needed to serialize the target object.

Applies to

See Also