System.AppDomainManager.InitializeNewDomain Method

Initializes the new application domain.

Syntax

public virtual void InitializeNewDomain (AppDomainSetup appDomainInfo)

Parameters

appDomainInfo
An object that contains application domain initialization information.

Remarks

Note:

Do not use this method to initialize an application domain in ASP.NET. In ASP.NET, configuration must be handled by the host. If you use this method to initialize the application domain, the host throws InvalidOperationException when it attempts to initialize the application domain. The exception message indicates that initialization has already occurred.

This method is called immediately after the constructor. The default AppDomainManager.InitializeNewDomain(AppDomainSetup) implementation does nothing. A custom implementation can set up internal classes and delegates, set up an interface with the unmanaged host interface, or set up event handlers for the new AppDomain.

Also, for add-in activations, a custom implementation could identify the current AppDomain as the target application domain.

Beginning with the net_v40_long, you can use this method to sandbox the default application domain at application startup, or to modify the sandbox of a new application domain. To do this, adjust the System.Security.Policy.ApplicationTrust.DefaultGrantSet and System.Security.Policy.ApplicationTrust.FullTrustAssemblies properties on the System.Security.Policy.ApplicationTrust object that is assigned to the AppDomainSetup.ApplicationTrust property of appDomainInfo, before you initialize the application domain.

Note:

Only assemblies granted FullTrust, such as assemblies in the global assembly cache or identified as fullTrustAssemblies in the AppDomain.CreateDomain(string, System.Security.Policy.Evidence, AppDomainSetup, System.Security.PermissionSet, System.Security.Policy.StrongName[]) method can be loaded in the AppDomainManager.#ctor constructor and the AppDomainManager.InitializeNewDomain(AppDomainSetup) method.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0