AppDomain.ExecuteAssembly 方法

定义

执行指定文件中包含的程序集。

重载

ExecuteAssembly(String, Evidence, String[], Byte[], AssemblyHashAlgorithm)
已过时.

使用指定的证据、自变量、哈希值和哈希算法执行指定文件中包含的程序集。

ExecuteAssembly(String, Evidence, String[])
已过时.

使用指定的证据和自变量执行指定文件中包含的程序集。

ExecuteAssembly(String, String[], Byte[], AssemblyHashAlgorithm)
已过时.

使用指定的自变量、哈希值和哈希算法执行指定文件中包含的程序集。

ExecuteAssembly(String, Evidence)
已过时.

使用指定的证据执行指定文件中包含的程序集。

ExecuteAssembly(String, String[])

使用指定的自变量执行指定文件中包含的程序集。

ExecuteAssembly(String)

执行指定文件中包含的程序集。

ExecuteAssembly(String, Evidence, String[], Byte[], AssemblyHashAlgorithm)

注意

Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of ExecuteAssembly which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.

使用指定的证据、自变量、哈希值和哈希算法执行指定文件中包含的程序集。

public:
 int ExecuteAssembly(System::String ^ assemblyFile, System::Security::Policy::Evidence ^ assemblySecurity, cli::array <System::String ^> ^ args, cli::array <System::Byte> ^ hashValue, System::Configuration::Assemblies::AssemblyHashAlgorithm hashAlgorithm);
public int ExecuteAssembly (string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args, byte[] hashValue, System.Configuration.Assemblies.AssemblyHashAlgorithm hashAlgorithm);
[System.Obsolete("Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of ExecuteAssembly which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
public int ExecuteAssembly (string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args, byte[] hashValue, System.Configuration.Assemblies.AssemblyHashAlgorithm hashAlgorithm);
member this.ExecuteAssembly : string * System.Security.Policy.Evidence * string[] * byte[] * System.Configuration.Assemblies.AssemblyHashAlgorithm -> int
[<System.Obsolete("Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of ExecuteAssembly which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")>]
member this.ExecuteAssembly : string * System.Security.Policy.Evidence * string[] * byte[] * System.Configuration.Assemblies.AssemblyHashAlgorithm -> int
Public Function ExecuteAssembly (assemblyFile As String, assemblySecurity As Evidence, args As String(), hashValue As Byte(), hashAlgorithm As AssemblyHashAlgorithm) As Integer

参数

assemblyFile
String

包含要执行程序集的文件的名称。

assemblySecurity
Evidence

为程序集提供的证据。

args
String[]

程序集的入口点的自变量。

hashValue
Byte[]

表示计算所得的哈希代码的值。

hashAlgorithm
AssemblyHashAlgorithm

表示程序集清单使用的哈希算法。

返回

程序集的入口点返回的值。

属性

例外

assemblyFilenull

assemblyFile 未找到。

assemblyFile 对于当前加载的运行时,不是有效的程序集。

在卸载的应用程序域上尝试该操作。

一个程序集或模块用两个不同的证据加载了两次。

assemblySecurity 不是 null。 未启用旧版 CAS 策略时,assemblySecurity 应为 null

指定的程序集没有入口点。

示例

以下示例演示如何在两个不同域上使用 的 ExecuteAssembly 一个重载。

int main()
{
   AppDomain^ currentDomain = AppDomain::CurrentDomain;
   AppDomain^ otherDomain = AppDomain::CreateDomain( "otherDomain" );
   currentDomain->ExecuteAssembly( "MyExecutable.exe" );
   
   // Prints S"MyExecutable running on [default]"
   otherDomain->ExecuteAssembly( "MyExecutable.exe" );
   
   // Prints S"MyExecutable running on otherDomain"
}
class ExecuteAssemblySnippet {
   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"
   }
}
open System

let currentDomain = AppDomain.CurrentDomain
let otherDomain = AppDomain.CreateDomain "otherDomain"

currentDomain.ExecuteAssembly "MyExecutable.exe"
// Prints "MyExecutable running on [default]"

otherDomain.ExecuteAssembly "MyExecutable.exe"
// Prints "MyExecutable running on otherDomain"
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

End Module 'Test

注解

程序集在 .NET Framework 标头中指定的入口点开始执行。

此方法不会创建新的进程或应用程序域,也不会在新线程上执行入口点方法。

此方法使用 LoadFile 方法加载程序集。 还可以使用 ExecuteAssemblyByName 方法执行程序集,该方法使用 Load 方法加载程序集。

适用于

ExecuteAssembly(String, Evidence, String[])

注意

Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of ExecuteAssembly which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.

使用指定的证据和自变量执行指定文件中包含的程序集。

public:
 virtual int ExecuteAssembly(System::String ^ assemblyFile, System::Security::Policy::Evidence ^ assemblySecurity, cli::array <System::String ^> ^ args);
public int ExecuteAssembly (string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args);
[System.Obsolete("Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of ExecuteAssembly which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
public int ExecuteAssembly (string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args);
abstract member ExecuteAssembly : string * System.Security.Policy.Evidence * string[] -> int
override this.ExecuteAssembly : string * System.Security.Policy.Evidence * string[] -> int
[<System.Obsolete("Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of ExecuteAssembly which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")>]
abstract member ExecuteAssembly : string * System.Security.Policy.Evidence * string[] -> int
override this.ExecuteAssembly : string * System.Security.Policy.Evidence * string[] -> int
Public Function ExecuteAssembly (assemblyFile As String, assemblySecurity As Evidence, args As String()) As Integer

参数

assemblyFile
String

包含要执行程序集的文件的名称。

assemblySecurity
Evidence

为程序集提供的证据。

args
String[]

程序集的入口点的自变量。

返回

程序集的入口点返回的值。

实现

属性

例外

assemblyFilenull

assemblyFile 未找到。

assemblyFile 对于当前加载的运行时,不是有效的程序集。

在卸载的应用程序域上尝试该操作。

一个程序集或模块用两个不同的证据加载了两次。

assemblySecurity 不是 null。 未启用旧版 CAS 策略时,assemblySecurity 应为 null

指定的程序集没有入口点。

示例

以下示例演示如何在两个不同域上使用 的 ExecuteAssembly 一个重载。

int main()
{
   AppDomain^ currentDomain = AppDomain::CurrentDomain;
   AppDomain^ otherDomain = AppDomain::CreateDomain( "otherDomain" );
   currentDomain->ExecuteAssembly( "MyExecutable.exe" );
   
   // Prints S"MyExecutable running on [default]"
   otherDomain->ExecuteAssembly( "MyExecutable.exe" );
   
   // Prints S"MyExecutable running on otherDomain"
}
class ExecuteAssemblySnippet {
   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"
   }
}
open System

let currentDomain = AppDomain.CurrentDomain
let otherDomain = AppDomain.CreateDomain "otherDomain"

currentDomain.ExecuteAssembly "MyExecutable.exe"
// Prints "MyExecutable running on [default]"

otherDomain.ExecuteAssembly "MyExecutable.exe"
// Prints "MyExecutable running on otherDomain"
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

End Module 'Test

注解

程序集在 .NET Framework 标头中指定的入口点开始执行。

此方法不会创建新的进程或应用程序域,也不会在新线程上执行入口点方法。

此方法使用 LoadFile 方法加载程序集。 还可以使用 ExecuteAssemblyByName 方法执行程序集,该方法使用 Load 方法加载程序集。

适用于

ExecuteAssembly(String, String[], Byte[], AssemblyHashAlgorithm)

Source:
AppDomain.cs
Source:
AppDomain.cs
Source:
AppDomain.cs

注意

Code Access Security is not supported or honored by the runtime.

使用指定的自变量、哈希值和哈希算法执行指定文件中包含的程序集。

public:
 int ExecuteAssembly(System::String ^ assemblyFile, cli::array <System::String ^> ^ args, cli::array <System::Byte> ^ hashValue, System::Configuration::Assemblies::AssemblyHashAlgorithm hashAlgorithm);
public int ExecuteAssembly (string assemblyFile, string?[]? args, byte[]? hashValue, System.Configuration.Assemblies.AssemblyHashAlgorithm hashAlgorithm);
[System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public int ExecuteAssembly (string assemblyFile, string?[]? args, byte[]? hashValue, System.Configuration.Assemblies.AssemblyHashAlgorithm hashAlgorithm);
public int ExecuteAssembly (string assemblyFile, string[] args, byte[] hashValue, System.Configuration.Assemblies.AssemblyHashAlgorithm hashAlgorithm);
member this.ExecuteAssembly : string * string[] * byte[] * System.Configuration.Assemblies.AssemblyHashAlgorithm -> int
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
member this.ExecuteAssembly : string * string[] * byte[] * System.Configuration.Assemblies.AssemblyHashAlgorithm -> int
Public Function ExecuteAssembly (assemblyFile As String, args As String(), hashValue As Byte(), hashAlgorithm As AssemblyHashAlgorithm) As Integer

参数

assemblyFile
String

包含要执行程序集的文件的名称。

args
String[]

程序集的入口点的自变量。

hashValue
Byte[]

表示计算所得的哈希代码的值。

hashAlgorithm
AssemblyHashAlgorithm

表示程序集清单使用的哈希算法。

返回

程序集的入口点返回的值。

属性

例外

assemblyFilenull

assemblyFile 未找到。

assemblyFile 对于当前加载的运行时,不是有效的程序集。

在卸载的应用程序域上尝试该操作。

一个程序集或模块用两个不同的证据加载了两次。

指定的程序集没有入口点。

示例

以下示例演示如何在两个不同域上使用 的 ExecuteAssembly 一个重载。

int main()
{
   AppDomain^ currentDomain = AppDomain::CurrentDomain;
   AppDomain^ otherDomain = AppDomain::CreateDomain( "otherDomain" );
   currentDomain->ExecuteAssembly( "MyExecutable.exe" );
   
   // Prints S"MyExecutable running on [default]"
   otherDomain->ExecuteAssembly( "MyExecutable.exe" );
   
   // Prints S"MyExecutable running on otherDomain"
}
class ExecuteAssemblySnippet {
   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"
   }
}
open System

let currentDomain = AppDomain.CurrentDomain
let otherDomain = AppDomain.CreateDomain "otherDomain"

currentDomain.ExecuteAssembly "MyExecutable.exe"
// Prints "MyExecutable running on [default]"

otherDomain.ExecuteAssembly "MyExecutable.exe"
// Prints "MyExecutable running on otherDomain"
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

End Module 'Test

注解

注意

代码访问安全性 (CAS) 已在所有版本的 .NET Framework 和 .NET 中弃用。 如果使用与 CAS 相关的 API,最新版本的 .NET 不会遵循 CAS 注释,并会生成错误。 开发人员应寻求用于完成安全任务的替代方法。

程序集在 .NET Framework 标头中指定的入口点开始执行。

此方法不会创建新的进程或应用程序域,也不会在新线程上执行入口点方法。

此方法使用 LoadFile 方法加载程序集。 还可以使用 ExecuteAssemblyByName 方法执行程序集,该方法使用 Load 方法加载程序集。

适用于

ExecuteAssembly(String, Evidence)

注意

Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of ExecuteAssembly which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.

使用指定的证据执行指定文件中包含的程序集。

public:
 virtual int ExecuteAssembly(System::String ^ assemblyFile, System::Security::Policy::Evidence ^ assemblySecurity);
public int ExecuteAssembly (string assemblyFile, System.Security.Policy.Evidence assemblySecurity);
[System.Obsolete("Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of ExecuteAssembly which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
public int ExecuteAssembly (string assemblyFile, System.Security.Policy.Evidence assemblySecurity);
abstract member ExecuteAssembly : string * System.Security.Policy.Evidence -> int
override this.ExecuteAssembly : string * System.Security.Policy.Evidence -> int
[<System.Obsolete("Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of ExecuteAssembly which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")>]
abstract member ExecuteAssembly : string * System.Security.Policy.Evidence -> int
override this.ExecuteAssembly : string * System.Security.Policy.Evidence -> int
Public Function ExecuteAssembly (assemblyFile As String, assemblySecurity As Evidence) As Integer

参数

assemblyFile
String

包含要执行程序集的文件的名称。

assemblySecurity
Evidence

用于加载程序集的证据。

返回

程序集的入口点返回的值。

实现

属性

例外

assemblyFilenull

assemblyFile 未找到。

assemblyFile 对于当前加载的运行时,不是有效的程序集。

在卸载的应用程序域上尝试该操作。

一个程序集或模块用两个不同的证据加载了两次。

指定的程序集没有入口点。

示例

以下示例演示如何在两个不同域上使用 的 ExecuteAssembly 一个重载。

int main()
{
   AppDomain^ currentDomain = AppDomain::CurrentDomain;
   AppDomain^ otherDomain = AppDomain::CreateDomain( "otherDomain" );
   currentDomain->ExecuteAssembly( "MyExecutable.exe" );
   
   // Prints S"MyExecutable running on [default]"
   otherDomain->ExecuteAssembly( "MyExecutable.exe" );
   
   // Prints S"MyExecutable running on otherDomain"
}
class ExecuteAssemblySnippet {
   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"
   }
}
open System

let currentDomain = AppDomain.CurrentDomain
let otherDomain = AppDomain.CreateDomain "otherDomain"

currentDomain.ExecuteAssembly "MyExecutable.exe"
// Prints "MyExecutable running on [default]"

otherDomain.ExecuteAssembly "MyExecutable.exe"
// Prints "MyExecutable running on otherDomain"
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

End Module 'Test

注解

程序集在 .NET Framework 标头中指定的入口点开始执行。

方法 ExecuteAssembly 不创建新的进程或应用程序域,也不会在新线程上执行入口点方法。

此方法使用 LoadFile 方法加载程序集。 还可以使用 ExecuteAssemblyByName 方法执行程序集,该方法使用 Load 方法加载程序集。

适用于

ExecuteAssembly(String, String[])

Source:
AppDomain.cs
Source:
AppDomain.cs
Source:
AppDomain.cs

使用指定的自变量执行指定文件中包含的程序集。

public:
 int ExecuteAssembly(System::String ^ assemblyFile, cli::array <System::String ^> ^ args);
public int ExecuteAssembly (string assemblyFile, string?[]? args);
public int ExecuteAssembly (string assemblyFile, string[] args);
member this.ExecuteAssembly : string * string[] -> int
Public Function ExecuteAssembly (assemblyFile As String, args As String()) As Integer

参数

assemblyFile
String

包含要执行程序集的文件的名称。

args
String[]

程序集的入口点的自变量。

返回

程序集的入口点返回的值。

例外

assemblyFilenull

assemblyFile 未找到。

assemblyFile 对于当前加载的运行时,不是有效的程序集。

在卸载的应用程序域上尝试该操作。

一个程序集或模块用两个不同的证据加载了两次。

指定的程序集没有入口点。

示例

以下示例演示如何在两个不同域上使用 的 ExecuteAssembly 一个重载。

int main()
{
   AppDomain^ currentDomain = AppDomain::CurrentDomain;
   AppDomain^ otherDomain = AppDomain::CreateDomain( "otherDomain" );
   currentDomain->ExecuteAssembly( "MyExecutable.exe" );
   
   // Prints S"MyExecutable running on [default]"
   otherDomain->ExecuteAssembly( "MyExecutable.exe" );
   
   // Prints S"MyExecutable running on otherDomain"
}
class ExecuteAssemblySnippet {
   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"
   }
}
open System

let currentDomain = AppDomain.CurrentDomain
let otherDomain = AppDomain.CreateDomain "otherDomain"

currentDomain.ExecuteAssembly "MyExecutable.exe"
// Prints "MyExecutable running on [default]"

otherDomain.ExecuteAssembly "MyExecutable.exe"
// Prints "MyExecutable running on otherDomain"
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

End Module 'Test

注解

程序集开始在 .NET Framework 标头中指定的入口点处执行。

此方法不会创建新的进程或应用程序域,也不会在新线程上执行入口点方法。

此方法使用 LoadFile 方法加载程序集。 还可以使用 ExecuteAssemblyByName 方法执行程序集,该方法使用 Load 方法加载程序集。

适用于

ExecuteAssembly(String)

Source:
AppDomain.cs
Source:
AppDomain.cs
Source:
AppDomain.cs

执行指定文件中包含的程序集。

public:
 int ExecuteAssembly(System::String ^ assemblyFile);
public:
 virtual int ExecuteAssembly(System::String ^ assemblyFile);
public int ExecuteAssembly (string assemblyFile);
member this.ExecuteAssembly : string -> int
abstract member ExecuteAssembly : string -> int
override this.ExecuteAssembly : string -> int
Public Function ExecuteAssembly (assemblyFile As String) As Integer

参数

assemblyFile
String

包含要执行程序集的文件的名称。

返回

程序集的入口点返回的值。

实现

例外

assemblyFilenull

assemblyFile 未找到。

assemblyFile 不是当前加载的运行时的有效程序集。

在卸载的应用程序域上尝试该操作。

一个程序集或模块用两个不同的证据加载了两次。

指定的程序集没有入口点。

示例

以下示例演示如何在两个不同的域中使用 的 ExecuteAssembly 重载之一。

int main()
{
   AppDomain^ currentDomain = AppDomain::CurrentDomain;
   AppDomain^ otherDomain = AppDomain::CreateDomain( "otherDomain" );
   currentDomain->ExecuteAssembly( "MyExecutable.exe" );
   
   // Prints S"MyExecutable running on [default]"
   otherDomain->ExecuteAssembly( "MyExecutable.exe" );
   
   // Prints S"MyExecutable running on otherDomain"
}
class ExecuteAssemblySnippet {
   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"
   }
}
open System

let currentDomain = AppDomain.CurrentDomain
let otherDomain = AppDomain.CreateDomain "otherDomain"

currentDomain.ExecuteAssembly "MyExecutable.exe"
// Prints "MyExecutable running on [default]"

otherDomain.ExecuteAssembly "MyExecutable.exe"
// Prints "MyExecutable running on otherDomain"
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

End Module 'Test

注解

程序集开始在 .NET Framework 标头中指定的入口点处执行。

此方法不会创建新的进程或应用程序域,也不会在新线程上执行入口点方法。

此方法使用 LoadFile 方法加载程序集。 还可以使用 ExecuteAssemblyByName 方法执行程序集,该方法使用 Load 方法加载程序集。

若要创建 AppDomain 要加载和执行的 ,请使用 CreateDomain 方法。

适用于