语言

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

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

返回

程序集入口点返回的值。

属性

例外

assemblyFile 是 null。

找不到 assemblyFile。

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

在卸载的应用程序域中尝试此操作。

程序集或模块加载了两次,其中包含两个不同的证据。

assemblySecurity 不是 null。 如果未启用旧 CAS 策略, assemblySecurity 应为 null。

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

适用于

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[]

程序集入口点的参数。

返回

程序集入口点返回的值。

实现

属性

例外

assemblyFile 是 null。

找不到 assemblyFile。

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

在卸载的应用程序域中尝试此操作。

程序集或模块加载了两次,其中包含两个不同的证据。

assemblySecurity 不是 null。 如果未启用旧 CAS 策略, assemblySecurity 应为 null。

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

适用于

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

Source:
AppDomain.cs
Source:
AppDomain.cs
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);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")]
[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);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")]
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);
public int ExecuteAssembly(string assemblyFile, string?[]? args, byte[]? hashValue, System.Configuration.Assemblies.AssemblyHashAlgorithm hashAlgorithm);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")>]
[<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
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")>]
member this.ExecuteAssembly : string * string[] * byte[] * System.Configuration.Assemblies.AssemblyHashAlgorithm -> int
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

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

返回

程序集入口点返回的值。

属性

例外

assemblyFile 是 null。

找不到 assemblyFile。

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

在卸载的应用程序域中尝试此操作。

程序集或模块加载了两次,其中包含两个不同的证据。

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

适用于

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

加载程序集的证据。

返回

程序集入口点返回的值。

实现

属性

例外

assemblyFile 是 null。

找不到 assemblyFile。

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

在卸载的应用程序域中尝试此操作。

程序集或模块加载了两次,其中包含两个不同的证据。

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

适用于

ExecuteAssembly(String, String[])

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

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

public:
 int ExecuteAssembly(System::String ^ assemblyFile, cli::array <System::String ^> ^ args);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")]
public int ExecuteAssembly(string assemblyFile, string?[]? args);
public int ExecuteAssembly(string assemblyFile, string[] args);
public int ExecuteAssembly(string assemblyFile, string?[]? args);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")>]
member this.ExecuteAssembly : string * string[] -> int
member this.ExecuteAssembly : string * string[] -> int
Public Function ExecuteAssembly (assemblyFile As String, args As String()) As Integer

参数

assemblyFile
String

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

args
String[]

程序集入口点的参数。

返回

程序集入口点返回的值。

属性

例外

assemblyFile 是 null。

找不到 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标头中指定的入口点执行。

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

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

适用于

ExecuteAssembly(String)

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

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

public:
 int ExecuteAssembly(System::String ^ assemblyFile);
public:
 virtual int ExecuteAssembly(System::String ^ assemblyFile);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")]
public int ExecuteAssembly(string assemblyFile);
public int ExecuteAssembly(string assemblyFile);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")>]
member this.ExecuteAssembly : string -> int
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

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

返回

程序集入口点返回的值。

实现

属性

例外

assemblyFile 是 null。

找不到 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标头中指定的入口点执行。

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

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

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

适用于