AppDomain::ExecuteAssembly Method (String, array<String>, array<Byte>, AssemblyHashAlgorithm)

.NET Framework 4.6 and 4.5

Executes the assembly contained in the specified file, using the specified arguments, hash value, and hash algorithm.

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

public:
int ExecuteAssembly(
	String^ assemblyFile, 
	array<String^>^ args, 
	array<unsigned char>^ hashValue, 
	AssemblyHashAlgorithm hashAlgorithm
)

Parameters

assemblyFile
Type: System::String

The name of the file that contains the assembly to execute.

args
Type: array<System::String>

The arguments to the entry point of the assembly.

hashValue
Type: array<System::Byte>

Represents the value of the computed hash code.

hashAlgorithm
Type: System.Configuration.Assemblies::AssemblyHashAlgorithm

Represents the hash algorithm used by the assembly manifest.

Return Value

Type: System::Int32
The value that is returned by the entry point of the assembly.

ExceptionCondition
ArgumentNullException

assemblyFile is nullptr.

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.

int main()
{
   AppDomain^ currentDomain = AppDomain::CurrentDomain;
   AppDomain^ otherDomain = AppDomain::CreateDomain( "otherDomain" );
   currentDomain->ExecuteAssembly( "MyExecutable.exe" );

   // Prints S"MyExecutable running on [default]"
   otherDomain->ExecuteAssembly( "MyExecutable.exe" );

   // Prints S"MyExecutable running on otherDomain"
}

.NET Framework

Supported in: 4.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft