AppDomainManager Class

Provides a managed equivalent of an unmanaged host.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
<ComVisibleAttribute(True)> _
<SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags := SecurityPermissionFlag.Infrastructure)> _
Public Class AppDomainManager _
	Inherits MarshalByRefObject

The AppDomainManager type exposes the following members.

  NameDescription
Public methodSupported by the XNA FrameworkAppDomainManagerInitializes a new instance of the AppDomainManager class.
Top

  NameDescription
Public propertyApplicationActivatorGets the application activator that handles the activation of add-ins and manifest-based applications for the domain.
Public propertyEntryAssemblyGets the entry assembly for an application.
Public propertyHostExecutionContextManagerGets the host execution context manager that manages the flow of the execution context.
Public propertyHostSecurityManagerGets the host security manager that participates in security decisions for the application domain.
Public propertySupported by the XNA FrameworkInitializationFlagsGets the initialization flags for custom application domain managers.
Top

  NameDescription
Public methodCheckSecuritySettingsIndicates whether the specified operation is allowed in the application domain.
Public methodCreateDomainReturns a new or existing application domain.
Protected methodStatic memberCreateDomainHelperProvides a helper method to create an application domain.
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public methodSupported by the XNA FrameworkEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by the XNA FrameworkFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by the XNA FrameworkGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodSupported by the XNA FrameworkGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodSupported by the XNA FrameworkInitializeNewDomainInitializes the new application domain.
Protected methodSupported by the XNA FrameworkMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodMemberwiseClone(Boolean)Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)
Public methodSupported by the XNA FrameworkToStringReturns a string that represents the current object. (Inherited from Object.)
Top

ExceptionCondition
SecurityException

The caller does not have the correct permissions. See the Requirements section.

Important noteImportant

Do not use AppDomainManager to configure an application domain in ASP.NET. In ASP.NET, configuration must be handled by the host.

Implementing the AppDomainManager class enables a hosting application to participate in the creation of new application domains. To replace the default AppDomainManager, identify the assembly and type of the replacement AppDomainManager in the APPDOMAIN_MANAGER_ASM and APPDOMAIN_MANAGER_TYPE environment variables, or use the <appDomainManagerAssembly> and <appDomainManagerType> elements in your configuration file. The assembly must be fully trusted and be contained in the global assembly cache or the directory of the starting application. The type and assembly names must be fully qualified in the environment variables. For example:

set APPDOMAIN_MANAGER_TYPE=MyNamespace.TestAppDomainManager

set APPDOMAIN_MANAGER_ASM=customappDomainmanager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f1368f7b12a08d72

Important noteImportant

If the assembly that contains your subclass of AppDomainManager depends on assemblies that are marked with the conditional AllowPartiallyTrustedCallersAttribute (APTCA) attribute, you must include those assemblies in the list that you pass to the PartialTrustVisibleAssemblies property of the AppDomainSetup you use to create application domains. Otherwise, the assemblies that are marked with the conditional APTCA attribute will be disabled.

The AppDomainManager is the managed equivalent of the unmanaged host. An AppDomainManager object participates in the creation of new application domains in a process and can customize the new AppDomain before other managed code runs. The AppDomainManager can also supply host managers that participate in other aspects of common language runtime execution. For example, an AppDomainManager can identify a HostSecurityManager object that participates in the security decisions of the 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, StrongName()) method can be loaded in the AppDomainManager constructor and the InitializeNewDomain method.

NoteNote

This class contains a link demand and an inheritance demand at the class level. A SecurityException is thrown when either the immediate caller or the derived class does not have infrastructure permission. For details about security demands, see Link Demands and Inheritance Demands.

The following example shows a very simple implementation of AppDomainManager.


' To replace the default AppDomainManager, identify  the 
' replacement assembly and replacement type in the 
' APPDOMAIN_MANAGER_ASM and APPDOMAIN_MANAGER_TYPE  
' environment variables. For example:
' set APPDOMAIN_MANAGER_TYPE=library.TestAppDomainManager
' set APPDOMAIN_MANAGER_ASM=library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f1368f7b12a08d72
Imports System
Imports System.Collections
Imports System.Net
Imports System.Reflection
Imports System.Security
Imports System.Security.Permissions
Imports System.Security.Policy
Imports System.Security.Principal
Imports System.Threading
Imports System.Runtime.InteropServices

<assembly: System.Security.AllowPartiallyTrustedCallersAttribute()>
<SecurityPermissionAttribute(SecurityAction.LinkDemand, _
    Flags:=SecurityPermissionFlag.Infrastructure)> _
<SecurityPermissionAttribute(SecurityAction.InheritanceDemand, _
    Flags:=SecurityPermissionFlag.Infrastructure)> _
<GuidAttribute("F4D15099-3407-4A7E-A607-DEA440CF3891")> _
Public Class MyAppDomainManager
    Inherits AppDomainManager
    Private mySecurityManager As HostSecurityManager = Nothing

    Public Sub New() 
        Console.WriteLine(" My AppDomain Manager ")
        mySecurityManager = AppDomain.CurrentDomain.CreateInstanceAndUnwrap( _
            "CustomSecurityManager, Version=1.0.0.3, Culture=neutral, " & _
            "PublicKeyToken=5659fc598c2a503e", "MyNamespace.MySecurityManager")
        Console.WriteLine(" Custom Security Manager Created.")    
    End Sub 'New

    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

    Public Overrides ReadOnly Property HostSecurityManager() _
        As HostSecurityManager 
        Get
            Return mySecurityManager
        End Get
    End Property
End Class 'MyAppDomainManager 


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft