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

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

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

'Declaration
Public Function ExecuteAssembly ( _
	assemblyFile As String, _
	assemblySecurity As Evidence, _
	args As String() _
) As Integer
'Usage
Dim instance As AppDomain 
Dim assemblyFile As String 
Dim assemblySecurity As Evidence 
Dim args As String()
Dim returnValue As Integer 

returnValue = instance.ExecuteAssembly(assemblyFile, _
	assemblySecurity, args)

Parameters

assemblyFile
Type: System.String

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

assemblySecurity
Type: System.Security.Policy.Evidence

The supplied evidence for the assembly.

args
Type: System.String()

The arguments to the entry point of the assembly.

Return Value

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

Implements

_AppDomain.ExecuteAssembly(String, Evidence, String())

ExceptionCondition
ArgumentNullException

assemblyFile is Nothing.

FileNotFoundException

assemblyFile is not found.

BadImageFormatException

assemblyFile is not a valid assembly.

-or-

Version 2.0 or later of the common language runtime is currently loaded and assemblyFile was compiled with a later version.

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.

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 example demonstrates using one of the overloads of ExecuteAssembly on two different domains.

Module Test

   Sub Main()
      Dim currentDomain As AppDomain = AppDomain.CurrentDomain
      Dim otherDomain As AppDomain = AppDomain.CreateDomain("otherDomain")

      currentDomain.ExecuteAssembly("MyExecutable.exe")
      ' Prints "MyExecutable running on [default]"

      otherDomain.ExecuteAssembly("MyExecutable.exe")
      ' Prints "MyExecutable running on otherDomain" 
   End Sub 'Main

End Module 'Test

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

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

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 3.0, 2.0, 1.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2015 Microsoft