AppDomainManager.InitializeNewDomain(AppDomainSetup) Method

Definition

Initializes the new application domain.

C#
public virtual void InitializeNewDomain(AppDomainSetup appDomainInfo);
C#
[System.Security.SecurityCritical]
public virtual void InitializeNewDomain(AppDomainSetup appDomainInfo);

Parameters

appDomainInfo
AppDomainSetup

An object that contains application domain initialization information.

Attributes

Examples

The following example shows an override of the InitializeNewDomain method for a custom application domain manager. This code example is part of a larger example provided for the AppDomainManager class.

C#
public override void InitializeNewDomain(AppDomainSetup appDomainInfo)
{
    Console.Write("Initialize new domain called:  ");
    Console.WriteLine(AppDomain.CurrentDomain.FriendlyName);
    InitializationFlags =
        AppDomainManagerInitializationOptions.RegisterWithHost;
}

Remarks

Važno

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 InitializeNewDomain 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 Framework 4, 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 DefaultGrantSet and FullTrustAssemblies properties on the ApplicationTrust object that is assigned to the AppDomainSetup.ApplicationTrust property of appDomainInfo, before you initialize the application domain.

Napomena

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

Applies to

Proizvod Verzije
.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