Executes the assembly contained in the specified file, using the specified evidence.
[Visual Basic]
Overloads Public Overridable Function ExecuteAssembly( _
ByVal assemblyFile As String, _
ByVal assemblySecurity As Evidence _
) As Integer Implements _AppDomain.ExecuteAssembly
[C#]
public virtual int ExecuteAssembly(
string assemblyFile,
Evidence assemblySecurity
);
[C++]
public: virtual int ExecuteAssembly(
String* assemblyFile,
Evidence* assemblySecurity
);
[JScript]
public 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.
Implements
_AppDomain.ExecuteAssembly
Exceptions
Remarks
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.
Example
[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")
currentDomain.ExecuteAssembly("MyExecutable.exe")
' Prints "MyExecutable running on [default]"
otherDomain.ExecuteAssembly("MyExecutable.exe")
' Prints "MyExecutable running on otherDomain"
End Sub 'Main
End Module 'Test
[C#]
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"
}
}
[C++]
int main() {
AppDomain* currentDomain = AppDomain::CurrentDomain;
AppDomain* otherDomain = AppDomain::CreateDomain(S"otherDomain");
currentDomain->ExecuteAssembly(S"MyExecutable.exe");
// Prints S"MyExecutable running on [default]"
otherDomain->ExecuteAssembly(S"MyExecutable.exe");
// 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
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
.NET Framework Security:
See Also
AppDomain Class | AppDomain Members | System Namespace | AppDomain.ExecuteAssembly Overload List