InitializeNewDomain Method
.NET Framework Class Library
AppDomainManager..::.InitializeNewDomain Method

Initializes the new application domain.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)
Visual Basic (Declaration)
Public Overridable Sub InitializeNewDomain ( _
    appDomainInfo As AppDomainSetup _
)
Visual Basic (Usage)
Dim instance As AppDomainManager
Dim appDomainInfo As AppDomainSetup

instance.InitializeNewDomain(appDomainInfo)
C#
public virtual void InitializeNewDomain(
    AppDomainSetup appDomainInfo
)
Visual C++
public:
virtual void InitializeNewDomain(
    AppDomainSetup^ appDomainInfo
)
JScript
public function InitializeNewDomain(
    appDomainInfo : AppDomainSetup
)

Parameters

appDomainInfo
Type: System..::.AppDomainSetup
An AppDomainSetup object that contains application domain initialization information.
Important noteImportant 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 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.

NoteNote:

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

The following code sample 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.

Visual Basic
Public Overrides Sub InitializeNewDomain(ByVal appDomainInfo _
    As AppDomainSetup) 
    Console.Write("Initialize new domain called:  ")
    Console.WriteLine(AppDomain.CurrentDomain.FriendlyName)
    InitializationFlags = _
        AppDomainManagerInitializationOptions.RegisterWithHost   
End Sub 'InitializeNewDomain
C#
public override void InitializeNewDomain(AppDomainSetup appDomainInfo)
{
    Console.Write("Initialize new domain called:  ");
    Console.WriteLine(AppDomain.CurrentDomain.FriendlyName);
    InitializationFlags = 
        AppDomainManagerInitializationOptions.RegisterWithHost;
}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Xbox 360

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

XNA Framework

Supported in: 1.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
Page view tracker