ActivationContext Class
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
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
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.
Importante
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.
Application |
Gets the ClickOnce application manifest for the current application. |
Deployment |
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. |
Create |
Initializes a new instance of the ActivationContext class using the specified application identity and array of manifest paths. |
Create |
Initializes a new instance of the ActivationContext class using the specified application identity. |
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. |
Get |
Serves as the default hash function. (Inherited from Object) |
Get |
Gets the Type of the current instance. (Inherited from Object) |
Memberwise |
Creates a shallow copy of the current Object. (Inherited from Object) |
To |
Returns a string that represents the current object. (Inherited from Object) |
ISerializable. |
Populates a SerializationInfo with the data needed to serialize the target object. |
Prodotto | Versioni |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Feedback su .NET
.NET è un progetto di open source. Selezionare un collegamento per fornire feedback: