AppDomain.ExecuteAssembly Method (String, String[])
![]() |
---|
The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience. |
Executes the assembly contained in the specified file, using the specified arguments.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- assemblyFile
-
Type:
System.String
The name of the file that contains the assembly to execute.
- args
-
Type:
System.String[]
The arguments to the entry point of the assembly.
Exception | Condition |
---|---|
ArgumentNullException | assemblyFile is null. |
FileNotFoundException | assemblyFile is not found. |
BadImageFormatException | assemblyFile is not a valid assembly. -or- assemblyFile was compiled with a later version of the common language runtime than the version that is currently loaded. |
AppDomainUnloadedException | The operation is attempted on an unloaded application domain. |
FileLoadException | An assembly or module was loaded twice with two different evidences. |
MissingMethodException | The specified assembly has no entry point. |
The assembly begins executing at the entry point specified in the .NET Framework header.
This method does not create a new process or application domain, and it does not execute the entry point method on a new thread.
This method loads assemblies using the LoadFile method. You can also execute assemblies using the ExecuteAssemblyByName method, which loads assemblies using the Load method.
The following sample demonstrates using one of the overloads of ExecuteAssembly on two different domains.
for access to read from a file or directory, and for access to the information in the path itself. Associated enumerations: FileIOPermissionAccess.Read, FileIOPermissionAccess.PathDiscovery.
for reading a URI that does not begin with "file://".
to execute a console application. Associated enumeration: PermissionState.Unrestricted.
Available since 4.0