次の方法で共有


AppDomain.ExecuteAssembly メソッド (String, Evidence, String )

指定したファイルに格納されているアセンブリを、指定した証拠と引数を使用して実行します。

Overloads Public Overridable Function ExecuteAssembly( _
   ByVal assemblyFile As String, _   ByVal assemblySecurity As Evidence, _   ByVal args() As String _) As Integer Implements _AppDomain.ExecuteAssembly
[C#]
public virtual int ExecuteAssembly(stringassemblyFile,EvidenceassemblySecurity,string[] args);
[C++]
public: virtual int ExecuteAssembly(String* assemblyFile,Evidence* assemblySecurity,String* args __gc[]);
[JScript]
public function ExecuteAssembly(
   assemblyFile : String,assemblySecurity : Evidence,args : String[]) : int;

パラメータ

  • assemblyFile
    実行するアセンブリが格納されているファイルの名前。
  • assemblySecurity
    アセンブリに指定する証拠。
  • args
    アセンブリのエントリ ポイントに渡す引数。

戻り値

アセンブリのエントリ ポイントが返す値。

実装

_AppDomain.ExecuteAssembly

例外

例外の種類 条件
ArgumentNullException assemblyFile が null 参照 (Visual Basic では Nothing) です。
FileNotFoundException assemblyFile が見つかりません。
BadImageFormatException assemblyFile が有効なアセンブリではありません。
AppDomainUnloadedException 操作が、アンロードされたアプリケーション ドメインで試行されています。
SecurityException 呼び出し元に、正しいアクセス許可がありません。要件のセクションを参照してください。

解説

アセンブリは、.NET Framework ヘッダーに指定されているエントリ ポイントで実行を開始します。

このメソッドでは、新しいプロセスやアプリケーション ドメインは作成しません。また、新しいスレッドでのエントリ ポイント メソッドも実行しません。

.NET Compact Framework - Windows CE .NET プラットフォームに関する注意点: .NET Compact Framework では、複数のアプリケーション ドメインで使用するためにアセンブリをドメインに中立なコード領域に読み込むことはできません。

使用例

[Visual Basic, C#, C++] 2 つの異なるドメインで ExecuteAssembly のオーバーロードの 1 つを使用する方法を次の例に示します。

 
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] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

.NET Framework セキュリティ:

参照

AppDomain クラス | AppDomain メンバ | System 名前空間 | AppDomain.ExecuteAssembly オーバーロードの一覧