Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​AppDomain

Assembly: System.Runtime

Inheritance: object → MarshalByRefObject → AppDomain

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

Properties

public string
BaseDirectory
Gets the base directory that the assembly resolver uses to probe for assemblies.
public string
DynamicDirectory
Gets the directory that the assembly resolver uses to probe for dynamically created assemblies.
public string
FriendlyName
Gets the friendly name of this application domain.
public int
Id
Gets an integer that uniquely identifies the application domain within the process.
public bool
IsFullyTrusted
Gets a value that indicates whether assemblies that are loaded into the current application domain execute with full trust.
public bool
IsHomogenous
Gets a value that indicates whether the current application domain has a set of permissions that is granted to all assemblies that are loaded into the application domain.
public long
MonitoringSurvivedMemorySize
Gets the number of bytes that survived the last collection and that are known to be referenced by the current application domain.
public long
MonitoringTotalAllocatedMemorySize
Gets the total size, in bytes, of all memory allocations that have been made by the application domain since it was created, without subtracting memory that has been collected.
public TimeSpan
MonitoringTotalProcessorTime
Gets the total processor time that has been used by all threads while executing in the current application domain, since the process started.
public PermissionSet
PermissionSet
Gets the permission set of a sandboxed application domain.
public string
RelativeSearchPath
Gets the path under the base directory where the assembly resolver should probe for private assemblies.
SetupInformation
Gets the application domain configuration information for this instance.
public bool
ShadowCopyFiles
Gets an indication whether the application domain is configured to shadow copy files.

Methods

public void
AppendPrivatePath​(string path)
path The name of the directory to be appended to the private path.
Appends the specified directory name to the private path list.
public string
ApplyPolicy​(string assemblyName)
assemblyName The assembly display name, in the form provided by the <see cref="P:System.Reflection.Assembly.FullName" /> property.
Returns A string containing the assembly display name after policy has been applied.
Returns the assembly display name after policy has been applied.
public void
ClearPrivatePath​()
Resets the path that specifies the location of private assemblies to the empty string ("").
public void
ClearShadowCopyPath​()
Resets the list of directories containing shadow copied assemblies to the empty string ("").
public ObjectHandle
CreateInstance​(string assemblyName, string typeName)
assemblyName The display name of the assembly. See <see cref="P:System.Reflection.Assembly.FullName" /> .
typeName The fully qualified name of the requested type, including the namespace but not the assembly, as returned by the <see cref="P:System.Type.FullName" /> property.
Returns An object that is a wrapper for the new instance specified by <paramref name="typeName" /> . The return value needs to be unwrapped to access the real object.
Creates a new instance of the specified type defined in the specified assembly.
public ObjectHandle
CreateInstance​(string assemblyName, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes)
assemblyName The display name of the assembly. See <see cref="P:System.Reflection.Assembly.FullName" /> .
typeName The fully qualified name of the requested type, including the namespace but not the assembly, as returned by the <see cref="P:System.Type.FullName" /> property.
ignoreCase A Boolean value specifying whether to perform a case-sensitive search or not.
bindingAttr A combination of zero or more bit flags that affect the search for the <paramref name="typeName" /> constructor. If <paramref name="bindingAttr" /> is zero, a case-sensitive search for public constructors is conducted.
binder An object that enables the binding, coercion of argument types, invocation of members, and retrieval of <see cref="T:System.Reflection.MemberInfo" /> objects using reflection. If <paramref name="binder" /> is null, the default binder is used.
args The arguments to pass to the constructor. This array of arguments must match in number, order, and type the parameters of the constructor to invoke. If the parameterless constructor is preferred, <paramref name="args" /> must be an empty array or null.
culture Culture-specific information that governs the coercion of <paramref name="args" /> to the formal types declared for the <paramref name="typeName" /> constructor. If <paramref name="culture" /> is <see langword="null" /> , the <see cref="T:System.Globalization.CultureInfo" /> for the current thread is used.
activationAttributes An array of one or more attributes that can participate in activation. Typically, an array that contains a single <see cref="T:System.Runtime.Remoting.Activation.UrlAttribute" /> object that specifies the URL that is required to activate a remote object. This parameter is related to client-activated objects. Client activation is a legacy technology that is retained for backward compatibility but is not recommended for new development. Distributed applications should instead use Windows Communication Foundation.
Returns An object that is a wrapper for the new instance specified by <paramref name="typeName" /> . The return value needs to be unwrapped to access the real object.
Creates a new instance of the specified type defined in the specified assembly. Parameters specify a binder, binding flags, constructor arguments, culture-specific information used to interpret arguments, and optional activation attributes.
public ObjectHandle
CreateInstance​(string assemblyName, string typeName, object[] activationAttributes)
assemblyName The display name of the assembly. See <see cref="P:System.Reflection.Assembly.FullName" /> .
typeName The fully qualified name of the requested type, including the namespace but not the assembly, as returned by the <see cref="P:System.Type.FullName" /> property.
activationAttributes An array of one or more attributes that can participate in activation. Typically, an array that contains a single <see cref="T:System.Runtime.Remoting.Activation.UrlAttribute" /> object that specifies the URL that is required to activate a remote object. This parameter is related to client-activated objects.Client activation is a legacy technology that is retained for backward compatibility but is not recommended for new development. Distributed applications should instead use Windows Communication Foundation.
Returns An object that is a wrapper for the new instance specified by <paramref name="typeName" /> . The return value needs to be unwrapped to access the real object.
Creates a new instance of the specified type defined in the specified assembly. A parameter specifies an array of activation attributes.
public object
CreateInstanceAndUnwrap​(string assemblyName, string typeName)
assemblyName The display name of the assembly. See <see cref="P:System.Reflection.Assembly.FullName" /> .
typeName The fully qualified name of the requested type, including the namespace but not the assembly, as returned by the <see cref="P:System.Type.FullName" /> property.
Returns An instance of the object specified by <paramref name="typeName" /> .
Creates a new instance of the specified type. Parameters specify the assembly where the type is defined, and the name of the type.
public object
CreateInstanceAndUnwrap​(string assemblyName, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes)
assemblyName The display name of the assembly. See <see cref="P:System.Reflection.Assembly.FullName" /> .
typeName The fully qualified name of the requested type, including the namespace but not the assembly, as returned by the <see cref="P:System.Type.FullName" /> property.
ignoreCase A Boolean value specifying whether to perform a case-sensitive search or not.
bindingAttr A combination of zero or more bit flags that affect the search for the <paramref name="typeName" /> constructor. If <paramref name="bindingAttr" /> is zero, a case-sensitive search for public constructors is conducted.
binder An object that enables the binding, coercion of argument types, invocation of members, and retrieval of <see cref="T:System.Reflection.MemberInfo" /> objects using reflection. If <paramref name="binder" /> is null, the default binder is used.
args The arguments to pass to the constructor. This array of arguments must match in number, order, and type the parameters of the constructor to invoke. If the parameterless constructor is preferred, <paramref name="args" /> must be an empty array or null.
culture A culture-specific object used to govern the coercion of types. If <paramref name="culture" /> is <see langword="null" /> , the <see langword="CultureInfo" /> for the current thread is used.
activationAttributes An array of one or more attributes that can participate in activation. Typically, an array that contains a single <see cref="T:System.Runtime.Remoting.Activation.UrlAttribute" /> object. that specifies the URL that is required to activate a remote object. This parameter is related to client-activated objects. Client activation is a legacy technology that is retained for backward compatibility but is not recommended for new development. Distributed applications should instead use Windows Communication Foundation.
Returns An instance of the object specified by <paramref name="typeName" /> .
Creates a new instance of the specified type defined in the specified assembly, specifying whether the case of the type name is ignored; the binding attributes and the binder that are used to select the type to be created; the arguments of the constructor; the culture; and the activation attributes.
public object
CreateInstanceAndUnwrap​(string assemblyName, string typeName, object[] activationAttributes)
assemblyName The display name of the assembly. See <see cref="P:System.Reflection.Assembly.FullName" /> .
typeName The fully qualified name of the requested type, including the namespace but not the assembly, as returned by the <see cref="P:System.Type.FullName" /> property.
activationAttributes An array of one or more attributes that can participate in activation. Typically, an array that contains a single <see cref="T:System.Runtime.Remoting.Activation.UrlAttribute" /> object that specifies the URL that is required to activate a remote object. This parameter is related to client-activated objects.Client activation is a legacy technology that is retained for backward compatibility but is not recommended for new development. Distributed applications should instead use Windows Communication Foundation.
Returns An instance of the object specified by <paramref name="typeName" /> .
Creates a new instance of the specified type. Parameters specify the assembly where the type is defined, the name of the type, and an array of activation attributes.
public ObjectHandle
CreateInstanceFrom​(string assemblyFile, string typeName)
assemblyFile The name, including the path, of a file that contains an assembly that defines the requested type. The assembly is loaded using the <see cref="M:System.Reflection.Assembly.LoadFrom(System.String)" /> method.
typeName The fully qualified name of the requested type, including the namespace but not the assembly, as returned by the <see cref="P:System.Type.FullName" /> property.
Returns An object that is a wrapper for the new instance, or <see langword="null" /> if <paramref name="typeName" /> is not found. The return value needs to be unwrapped to access the real object.
Creates a new instance of the specified type defined in the specified assembly file.
public ObjectHandle
CreateInstanceFrom​(string assemblyFile, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes)
assemblyFile The name, including the path, of a file that contains an assembly that defines the requested type. The assembly is loaded using the <see cref="M:System.Reflection.Assembly.LoadFrom(System.String)" /> method.
typeName The fully qualified name of the requested type, including the namespace but not the assembly, as returned by the <see cref="P:System.Type.FullName" /> property.
ignoreCase A Boolean value specifying whether to perform a case-sensitive search or not.
bindingAttr A combination of zero or more bit flags that affect the search for the <paramref name="typeName" /> constructor. If <paramref name="bindingAttr" /> is zero, a case-sensitive search for public constructors is conducted.
binder An object that enables the binding, coercion of argument types, invocation of members, and retrieval of <see cref="T:System.Reflection.MemberInfo" /> objects through reflection. If <paramref name="binder" /> is null, the default binder is used.
args The arguments to pass to the constructor. This array of arguments must match in number, order, and type the parameters of the constructor to invoke. If the parameterless constructor is preferred, <paramref name="args" /> must be an empty array or null.
culture Culture-specific information that governs the coercion of <paramref name="args" /> to the formal types declared for the <paramref name="typeName" /> constructor. If <paramref name="culture" /> is <see langword="null" /> , the <see cref="T:System.Globalization.CultureInfo" /> for the current thread is used.
activationAttributes An array of one or more attributes that can participate in activation. Typically, an array that contains a single <see cref="T:System.Runtime.Remoting.Activation.UrlAttribute" /> object that specifies the URL that is required to activate a remote object. This parameter is related to client-activated objects. Client activation is a legacy technology that is retained for backward compatibility but is not recommended for new development. Distributed applications should instead use Windows Communication Foundation.
Returns An object that is a wrapper for the new instance, or <see langword="null" /> if <paramref name="typeName" /> is not found. The return value needs to be unwrapped to access the real object.
Creates a new instance of the specified type defined in the specified assembly file.
public ObjectHandle
CreateInstanceFrom​(string assemblyFile, string typeName, object[] activationAttributes)
assemblyFile The name, including the path, of a file that contains an assembly that defines the requested type. The assembly is loaded using the <see cref="M:System.Reflection.Assembly.LoadFrom(System.String)" /> method.
typeName The fully qualified name of the requested type, including the namespace but not the assembly, as returned by the <see cref="P:System.Type.FullName" /> property.
activationAttributes An array of one or more attributes that can participate in activation. Typically, an array that contains a single <see cref="T:System.Runtime.Remoting.Activation.UrlAttribute" /> object that specifies the URL that is required to activate a remote object. This parameter is related to client-activated objects.Client activation is a legacy technology that is retained for backward compatibility but is not recommended for new development. Distributed applications should instead use Windows Communication Foundation.
Returns An object that is a wrapper for the new instance, or <see langword="null" /> if <paramref name="typeName" /> is not found. The return value needs to be unwrapped to access the real object.
Creates a new instance of the specified type defined in the specified assembly file.
public object
CreateInstanceFromAndUnwrap​(string assemblyFile, string typeName)
typeName The fully qualified name of the requested type, including the namespace but not the assembly, as returned by the <see cref="P:System.Type.FullName" /> property.
Returns The requested object, or <see langword="null" /> if <paramref name="typeName" /> is not found.
Creates a new instance of the specified type defined in the specified assembly file.
public object
CreateInstanceFromAndUnwrap​(string assemblyFile, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes)
assemblyFile The file name and path of the assembly that defines the requested type.
typeName The fully qualified name of the requested type, including the namespace but not the assembly, as returned by the <see cref="P:System.Type.FullName" /> property.
ignoreCase A Boolean value specifying whether to perform a case-sensitive search or not.
bindingAttr A combination of zero or more bit flags that affect the search for the <paramref name="typeName" /> constructor. If <paramref name="bindingAttr" /> is zero, a case-sensitive search for public constructors is conducted.
binder An object that enables the binding, coercion of argument types, invocation of members, and retrieval of <see cref="T:System.Reflection.MemberInfo" /> objects through reflection. If <paramref name="binder" /> is null, the default binder is used.
args The arguments to pass to the constructor. This array of arguments must match in number, order, and type the parameters of the constructor to invoke. If the parameterless constructor is preferred, <paramref name="args" /> must be an empty array or null.
culture Culture-specific information that governs the coercion of <paramref name="args" /> to the formal types declared for the <paramref name="typeName" /> constructor. If <paramref name="culture" /> is <see langword="null" /> , the <see cref="T:System.Globalization.CultureInfo" /> for the current thread is used.
activationAttributes An array of one or more attributes that can participate in activation. Typically, an array that contains a single <see cref="T:System.Runtime.Remoting.Activation.UrlAttribute" /> object that specifies the URL that is required to activate a remote object. This parameter is related to client-activated objects. Client activation is a legacy technology that is retained for backward compatibility but is not recommended for new development. Distributed applications should instead use Windows Communication Foundation.
Returns The requested object, or <see langword="null" /> if <paramref name="typeName" /> is not found.
Creates a new instance of the specified type defined in the specified assembly file, specifying whether the case of the type name is ignored; the binding attributes and the binder that are used to select the type to be created; the arguments of the constructor; the culture; and the activation attributes.
public object
CreateInstanceFromAndUnwrap​(string assemblyFile, string typeName, object[] activationAttributes)
typeName The fully qualified name of the requested type, including the namespace but not the assembly (see the <see cref="P:System.Type.FullName" /> property).
activationAttributes An array of one or more attributes that can participate in activation. Typically, an array that contains a single <see cref="T:System.Runtime.Remoting.Activation.UrlAttribute" /> object that specifies the URL that is required to activate a remote object. This parameter is related to client-activated objects.Client activation is a legacy technology that is retained for backward compatibility but is not recommended for new development. Distributed applications should instead use Windows Communication Foundation.
Returns The requested object, or <see langword="null" /> if <paramref name="typeName" /> is not found.
Creates a new instance of the specified type defined in the specified assembly file.
public int
ExecuteAssembly​(string assemblyFile)
assemblyFile The name of the file that contains the assembly to execute.
Returns The value returned by the entry point of the assembly.
Executes the assembly contained in the specified file.
public int
ExecuteAssembly​(string assemblyFile, string[] args)
assemblyFile The name of the file that contains the assembly to execute.
args The arguments to the entry point of the assembly.
Returns The value that is returned by the entry point of the assembly.
Executes the assembly contained in the specified file, using the specified arguments.
public int
ExecuteAssembly​(string assemblyFile, string[] args, byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm)
assemblyFile The name of the file that contains the assembly to execute.
args The arguments to the entry point of the assembly.
hashValue Represents the value of the computed hash code.
hashAlgorithm Represents the hash algorithm used by the assembly manifest.
Returns The value that is returned by the entry point of the assembly.
Executes the assembly contained in the specified file, using the specified arguments, hash value, and hash algorithm.
public int
ExecuteAssemblyByName​(AssemblyName assemblyName, string[] args)
assemblyName An <see cref="T:System.Reflection.AssemblyName" /> object representing the name of the assembly.
args Command-line arguments to pass when starting the process.
Returns The value that is returned by the entry point of the assembly.
Executes the assembly given an <see cref="T:System.Reflection.AssemblyName" /> , using the specified arguments.
public int
ExecuteAssemblyByName​(string assemblyName)
assemblyName The display name of the assembly. See <see cref="P:System.Reflection.Assembly.FullName" /> .
Returns The value returned by the entry point of the assembly.
Executes an assembly given its display name.
public int
ExecuteAssemblyByName​(string assemblyName, string[] args)
assemblyName The display name of the assembly. See <see cref="P:System.Reflection.Assembly.FullName" /> .
args Command-line arguments to pass when starting the process.
Returns The value that is returned by the entry point of the assembly.
Executes the assembly given its display name, using the specified arguments.
public Assembly[]
GetAssemblies​()
Returns An array of assemblies in this application domain.
Gets the assemblies that have been loaded into the execution context of this application domain.
public object
GetData​(string name)
name The name of a predefined application domain property, or the name of an application domain property you have defined.
Returns The value of the <paramref name="name" /> property, or <see langword="null" /> if the property does not exist.
Gets the value stored in the current application domain for the specified name.
public Nullable`1
IsCompatibilitySwitchSet​(string value)
value The compatibility switch to test.
Returns A null reference ( <see langword="Nothing" /> in Visual Basic) if no compatibility switches are set; otherwise, a Boolean value that indicates whether the compatibility switch that is specified by <paramref name="value" /> is set.
Gets a nullable Boolean value that indicates whether any compatibility switches are set, and if so, whether the specified compatibility switch is set.
public bool
IsDefaultAppDomain​()
Returns <see langword="true" /> if the current <see cref="T:System.AppDomain" /> object represents the default application domain for the process; otherwise, <see langword="false" /> .
Returns a value that indicates whether the application domain is the default application domain for the process.
public bool
IsFinalizingForUnload​()
Returns <see langword="true" /> if this application domain is unloading and the common language runtime has started invoking finalizers; otherwise, <see langword="false" /> .
Indicates whether this application domain is unloading, and the objects it contains are being finalized by the common language runtime.
public Assembly
Load​(byte[] rawAssembly)
rawAssembly An array of type <see langword="byte" /> that is a COFF-based image containing an emitted assembly.
Returns The loaded assembly.
Loads the <see cref="T:System.Reflection.Assembly" /> with a common object file format (COFF) based image containing an emitted <see cref="T:System.Reflection.Assembly" /> .
public Assembly
Load​(byte[] rawAssembly, byte[] rawSymbolStore)
rawAssembly An array of type <see langword="byte" /> that is a COFF-based image containing an emitted assembly.
rawSymbolStore An array of type <see langword="byte" /> containing the raw bytes representing the symbols for the assembly.
Returns The loaded assembly.
Loads the <see cref="T:System.Reflection.Assembly" /> with a common object file format (COFF) based image containing an emitted <see cref="T:System.Reflection.Assembly" /> . The raw bytes representing the symbols for the <see cref="T:System.Reflection.Assembly" /> are also loaded.
public Assembly
Load​(AssemblyName assemblyRef)
assemblyRef An object that describes the assembly to load.
Returns The loaded assembly.
Loads an <see cref="T:System.Reflection.Assembly" /> given its <see cref="T:System.Reflection.AssemblyName" /> .
public Assembly
Load​(string assemblyString)
assemblyString The display name of the assembly. See <see cref="P:System.Reflection.Assembly.FullName" /> .
Returns The loaded assembly.
Loads an <see cref="T:System.Reflection.Assembly" /> given its display name.
public Assembly[]
ReflectionOnlyGetAssemblies​()
Returns An array of <see cref="T:System.Reflection.Assembly" /> objects that represent the assemblies loaded into the reflection-only context of the application domain.
Returns the assemblies that have been loaded into the reflection-only context of the application domain.
public void
SetCachePath​(string path)
path The fully qualified path to the shadow copy location.
Establishes the specified directory path as the location where assemblies are shadow copied.
public void
SetData​(string name, object data)
name The name of a user-defined application domain property to create or change.
data The value of the property.
Assigns the specified value to the specified application domain property.
public void
SetDynamicBase​(string path)
path The fully qualified path that is the base directory for subdirectories where dynamic assemblies are stored.
Establishes the specified directory path as the base directory for subdirectories where dynamically generated files are stored and accessed.
public void
SetPrincipalPolicy​(PrincipalPolicy policy)
policy One of the <see cref="T:System.Security.Principal.PrincipalPolicy" /> values that specifies the type of the principal object to attach to threads.
Specifies how principal and identity objects should be attached to a thread if the thread attempts to bind to a principal while executing in this application domain.
public void
SetShadowCopyFiles​()
Turns on shadow copying.
public void
SetShadowCopyPath​(string path)
path A list of directory names, where each name is separated by a semicolon.
Establishes the specified directory path as the location of assemblies to be shadow copied.
public void
SetThreadPrincipal​(IPrincipal principal)
principal The principal object to attach to threads.
Sets the default principal object to be attached to threads if they attempt to bind to a principal while executing in this application domain.
public string
ToString​()
Returns A string formed by concatenating the literal string "Name:", the friendly name of the application domain, and either string representations of the context policies or the string "There are no context policies."
Obtains a string representation that includes the friendly name of the application domain and any context policies.
public object
GetLifetimeService​()
Inherited from MarshalByRefObject
Returns An object of type <see cref="T:System.Runtime.Remoting.Lifetime.ILease" /> used to control the lifetime policy for this instance.
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
public object
InitializeLifetimeService​()
Inherited from MarshalByRefObject
Returns An object of type <see cref="T:System.Runtime.Remoting.Lifetime.ILease" /> used to control the lifetime policy for this instance. This is the current lifetime service object for this instance if one exists; otherwise, a new lifetime service object initialized to the value of the <see cref="P:System.Runtime.Remoting.Lifetime.LifetimeServices.LeaseManagerPollTime" /> property.
Obtains a lifetime service object to control the lifetime policy for this instance.
protected MarshalByRefObject
MemberwiseClone​(bool cloneIdentity)
Inherited from MarshalByRefObject
cloneIdentity <see langword="false" /> to delete the current <see cref="T:System.MarshalByRefObject" /> object's identity, which will cause the object to be assigned a new identity when it is marshaled across a remoting boundary. A value of <see langword="false" /> is usually appropriate. <see langword="true" /> to copy the current <see cref="T:System.MarshalByRefObject" /> object's identity to its clone, which will cause remoting client calls to be routed to the remote server object.
Returns A shallow copy of the current <see cref="T:System.MarshalByRefObject" /> object.
Creates a shallow copy of the current <see cref="T:System.MarshalByRefObject" /> object.
public bool
Equals​(object obj)
Inherited from object
obj The object to compare with the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
Determines whether the specified object is equal to the current object.
protected void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public int
GetHashCode​()
Inherited from object
Returns A hash code for the current object.
Serves as the default hash function.
public Type
GetType​()
Inherited from object
Returns The exact runtime type of the current instance.
Gets the <see cref="T:System.Type" /> of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Returns A shallow copy of the current <see cref="T:System.Object" /> .
Creates a shallow copy of the current <see cref="T:System.Object" /> .