語言

AppDomain.ExecuteAssembly 方法

定義

執行指定檔案中包含的組合語言。

多載

名稱 Description
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)

來源:
AppDomain.cs
來源:
AppDomain.cs
來源:
AppDomain.cs
來源:
AppDomain.cs
來源:
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[])

來源:
AppDomain.cs
來源:
AppDomain.cs
來源:
AppDomain.cs
來源:
AppDomain.cs
來源:
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)

來源:
AppDomain.cs
來源:
AppDomain.cs
來源:
AppDomain.cs
來源:
AppDomain.cs
來源:
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 方法。

適用於