System.AppDomain Class

Represents an application domain, which is an isolated environment where applications execute. This class cannot be inherited.

See Also: AppDomain Members

Syntax

[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Runtime.InteropServices.ComDefaultInterface(typeof(System._AppDomain))]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AppDomain : MarshalByRefObject, _AppDomain, System.Security.IEvidenceFactory

Remarks

Application domains, which are represented by AppDomain objects, help provide isolation, unloading, and security boundaries for executing managed code.

Multiple application domains can run in a single process; however, there is not a one-to-one correlation between application domains and threads. Several threads can belong to a single application domain, and while a given thread is not confined to a single application domain, at any given time, a thread executes in a single application domain.

Application domains are created using the AppDomain.CreateDomain(string, System.Security.Policy.Evidence) method. AppDomain instances are used to load and execute assemblies (System.Reflection.Assembly). When an AppDomain is no longer in use, it can be unloaded.

The AppDomain class implements a set of events that enable applications to respond when an assembly is loaded, when an application domain will be unloaded, or when an unhandled exception is thrown.

For more information on using application domains, see Application Domains.

This class implements the MarshalByRefObject, _AppDomain, and System.Security.IEvidenceFactory interfaces.

You should never create a remotable wrapper for an AppDomain object. Doing so could publish a remote reference to that AppDomain, exposing methods such as erload:System.AppDomain.CreateInstance to remote access and effectively destroying code access security for that AppDomain. Malicious clients connecting to the remoted AppDomain could obtain access to any resource the AppDomain itself has access to. Do not create remotable wrappers for any type that extends MarshalByRefObject and that implements methods that could be used by malicious clients to bypass the security system.

Note:

The default value for the AppDomainSetup.DisallowCodeDownload property is false. This setting is unsafe for services. To prevent services from downloading partially trusted code, set this property to true.

Thread Safety

All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0