Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
This topic has not yet been rated - Rate this topic

AppDomain.ExecuteAssembly Method (String)

Executes the assembly contained in the specified file.

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

public int ExecuteAssembly (
	string assemblyFile
)
public final int ExecuteAssembly (
	String assemblyFile
)
public final function ExecuteAssembly (
	assemblyFile : String
) : int

Parameters

assemblyFile

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

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.

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

To create the AppDomain to load and execute, use the CreateDomain method.

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

.NET Compact Framework

Supported in: 2.0, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft. All rights reserved.