ExecuteAssembly Method (String, Evidence, String[])

AppDomain.ExecuteAssembly Method (String, Evidence, String[])

.NET Framework 1.1

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

[Visual Basic]
Overloads Public Overridable Function ExecuteAssembly( _
   ByVal assemblyFile As String, _
   ByVal assemblySecurity As Evidence, _
   ByVal args() As String _
) As Integer Implements _AppDomain.ExecuteAssembly
public virtual int ExecuteAssembly(
 string assemblyFile,
 Evidence assemblySecurity,
 string[] args
public: virtual int ExecuteAssembly(
 String* assemblyFile,
 Evidence* assemblySecurity,
 String* args __gc[]
public function ExecuteAssembly(
   assemblyFile : String,
 assemblySecurity : Evidence,
 args : String[]
) : int;


The name of the file that contains the assembly to execute.
The supplied evidence for the assembly.
The arguments to the entry point of the assembly.

Return Value

The value returned by the entry point of the assembly.




Exception Type Condition
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.
SecurityException The caller does not have the correct permissions. See the requirements section.


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.

.NET Compact Framework Platform Note:  The .NET Compact Framework does not support loading assemblies into a domain neutral code area for use by multiple application domains.


[Visual Basic, C#, C++] The following sample demonstrates using one of the overloads of ExecuteAssembly on two different domains.

[Visual Basic] 
Module Test

   Sub Main()
      Dim currentDomain As AppDomain = AppDomain.CurrentDomain
      Dim otherDomain As AppDomain = AppDomain.CreateDomain("otherDomain")
      ' Prints "MyExecutable running on [default]"

      ' Prints "MyExecutable running on otherDomain"
   End Sub 'Main

End Module 'Test

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

      // Prints "MyExecutable running on otherDomain"

int main() {
   AppDomain* currentDomain = AppDomain::CurrentDomain;
   AppDomain* otherDomain = AppDomain::CreateDomain(S"otherDomain");

   // Prints S"MyExecutable running on [default]"

   // Prints S"MyExecutable running on otherDomain"

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

.NET Framework Security: 

See Also

AppDomain Class | AppDomain Members | System Namespace | AppDomain.ExecuteAssembly Overload List

© 2015 Microsoft