Provides a managed equivalent of an unmanaged host.
public ref class AppDomainManager : MarshalByRefObject
[System.Runtime.InteropServices.ComVisible(true)]
public class AppDomainManager : MarshalByRefObject
[System.Runtime.InteropServices.ComVisible(true)]
[System.Security.SecurityCritical]
public class AppDomainManager : MarshalByRefObject
[<System.Runtime.InteropServices.ComVisible(true)>]
type AppDomainManager = class
inherit MarshalByRefObject
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Security.SecurityCritical>]
type AppDomainManager = class
inherit MarshalByRefObject
Public Class AppDomainManager
Inherits MarshalByRefObject
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
using System;
using System.Collections;
using System.Net;
using System.Reflection;
using System.Security;
using System.Security.Policy;
using System.Security.Principal;
using System.Threading;
using System.Runtime.InteropServices;
[assembly: System.Security.AllowPartiallyTrustedCallersAttribute()]
namespace MyNamespace
{
[GuidAttribute("F4D15099-3407-4A7E-A607-DEA440CF3891")]
public class MyAppDomainManager : AppDomainManager
{
private HostSecurityManager mySecurityManager = null;
public MyAppDomainManager()
{
Console.WriteLine(" My AppDomain Manager ");
mySecurityManager = AppDomain.CurrentDomain.CreateInstanceAndUnwrap(
"CustomSecurityManager, Version=1.0.0.3, Culture=neutral, " +
"PublicKeyToken=5659fc598c2a503e",
"MyNamespace.MySecurityManager") as HostSecurityManager;
Console.WriteLine(" Custom Security Manager Created.");
}
public override void InitializeNewDomain(AppDomainSetup appDomainInfo)
{
Console.Write("Initialize new domain called: ");
Console.WriteLine(AppDomain.CurrentDomain.FriendlyName);
InitializationFlags =
AppDomainManagerInitializationOptions.RegisterWithHost;
}
public override HostSecurityManager HostSecurityManager
{
get
{
return mySecurityManager;
}
}
}
}
' 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.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
Public Overrides Sub InitializeNewDomain(ByVal appDomainInfo _
As AppDomainSetup)
Console.Write("Initialize new domain called: ")
Console.WriteLine(AppDomain.CurrentDomain.FriendlyName)
InitializationFlags = _
AppDomainManagerInitializationOptions.RegisterWithHost
End Sub
Public Overrides ReadOnly Property HostSecurityManager() _
As HostSecurityManager
Get
Return mySecurityManager
End Get
End Property
End Class
Important
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
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.
Note
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.
Constructors Properties ApplicationActivatorGets the application activator that handles the activation of add-ins and manifest-based applications for the domain.
EntryAssemblyGets the entry assembly for an application.
HostExecutionContextManagerGets the host execution context manager that manages the flow of the execution context.
HostSecurityManagerGets the host security manager that participates in security decisions for the application domain.
InitializationFlagsGets the initialization flags for custom application domain managers.
MethodsRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4