共用方式為


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)

來源:
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);
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。 最新版本的 .NET 不接受 CAS 批注,並在使用 CAS 相關 API 時產生錯誤。 開發人員應尋求替代方案來完成安全性工作。

元件會在 .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[])

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

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

若要建立 要載入和執行的 AppDomainCreateDomain ,請使用 方法。

適用於