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. 若要直接處置型別,請呼叫其 try/catch 區塊中的 Dispose 方法。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 物件嘗試釋放資源,並執行其他清除作業,不必等到記憶體回收利用 ActivationContextEnables 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 的淺層複本 (Shallow Copy)。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.

適用於

另請參閱