Export (0) Print
Expand All

AppDomain.ExecuteAssembly Method (String, Evidence)

Executes the assembly contained in the specified file, using the specified evidence.

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

public int ExecuteAssembly (
	string assemblyFile,
	Evidence assemblySecurity
)
public final int ExecuteAssembly (
	String assemblyFile, 
	Evidence assemblySecurity
)
public final function ExecuteAssembly (
	assemblyFile : String, 
	assemblySecurity : Evidence
) : int

Parameters

assemblyFile

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

assemblySecurity

Evidence for loading the assembly.

Return Value

The value returned by the entry point of the assembly.

Exception typeCondition

ArgumentNullException

assemblyFile is a null reference (Nothing in Visual Basic).

FileNotFoundException

assemblyFile is not found.

BadImageFormatException

assemblyFile is not a valid assembly.

AppDomainUnloadedException

Operations are attempted on an unloaded application domain.

FileLoadException

An assembly or module was loaded twice with two different evidences.

The assembly begins executing at the entry point specified in the .NET Framework header.

The ExecuteAssembly method does not create a new process or application domain, and it does not execute the entry point method on a new thread.

Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows CE Platform Note: Loading assemblies into a domain neutral code area for use by multiple application domains is not supported.

The following sample demonstrates using one of the overloads of ExecuteAssembly on two different domains.

class Test {
   public static void Main() {
      AppDomain currentDomain = AppDomain.CurrentDomain;
      AppDomain otherDomain = AppDomain.CreateDomain("otherDomain");
      
      currentDomain.ExecuteAssembly("MyExecutable.exe");
      // Prints "MyExecutable running on [default]"

      otherDomain.ExecuteAssembly("MyExecutable.exe");
      // Prints "MyExecutable running on otherDomain"
   }
}

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft