ActivationContext ActivationContext ActivationContext ActivationContext Class

定义

标识当前应用程序的激活上下文。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
type ActivationContext = class
    interface IDisposable
    interface ISerializable
Public NotInheritable Class ActivationContext
Implements IDisposable, ISerializable
继承
ActivationContextActivationContextActivationContextActivationContext
属性
实现

示例

下面的代码示例演示如何将ActivationContext对象,以获取ApplicationIdentity基于清单的应用程序。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

注解

ActivationContext类包含ApplicationIdentity并提供对应用程序清单的仅限内部使用的访问。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. 有关更多信息,请参见 ApplicationSecurityManager 类。For more information, see the ApplicationSecurityManager class.

重要

此类型实现IDisposable接口。This type implements the IDisposable interface. 在使用完类型后,您应直接或间接释放类型。When you have finished using the type, you should dispose of it either directly or indirectly. 若要直接释放类型,调用其Dispose中的方法try / catch块。To dispose of the type directly, call its Dispose method in a try/catch block. 若要间接释放类型,请使用 using(在 C# 中)或 Using(在 Visual Basic 中)等语言构造。To dispose of it indirectly, use a language construct such as using (in C#) or Using (in Visual Basic). 有关详细信息,请参阅中的"使用对象实现 IDisposable"一节IDisposable接口主题。For more information, see the "Using an Object that Implements IDisposable" section in the IDisposable interface topic.

属性

ApplicationManifestBytes ApplicationManifestBytes ApplicationManifestBytes ApplicationManifestBytes

获取当前应用程序的 ClickOnce 应用程序清单。Gets the ClickOnce application manifest for the current application.

DeploymentManifestBytes DeploymentManifestBytes DeploymentManifestBytes DeploymentManifestBytes

获取当前应用程序的 ClickOnce 部署清单。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.

方法

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

使用指定的应用程序标识初始化 ActivationContext 类的新实例。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[])

使用指定的应用程序标识和清单路径数组来初始化 ActivationContext 类的新实例。Initializes a new instance of the ActivationContext class using the specified application identity and array of manifest paths.

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

释放由 ActivationContext 使用的所有资源。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()

使 ActivationContext 对象在垃圾回收已收回 ActivationContext 之前尝试释放资源并执行其他清理操作。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()

获取当前实例的 TypeGets the Type of the current instance.

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

创建当前 Object 的浅表副本。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)

显式界面实现

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

使用将目标对象序列化所需的数据填充 SerializationInfoPopulates a SerializationInfo with the data needed to serialize the target object.

适用于

另请参阅