AppDomain.ExecuteAssembly Metoda

Definicja

Wykonuje zestaw zawarty w określonym pliku.

Przeciążenia

ExecuteAssembly(String, Evidence, String[], Byte[], AssemblyHashAlgorithm)
Przestarzałe.

Wykonuje zestaw zawarty w określonym pliku przy użyciu określonych dowodów, argumentów, wartości skrótu i algorytmu skrótu.

ExecuteAssembly(String, Evidence, String[])
Przestarzałe.

Wykonuje zestaw zawarty w określonym pliku przy użyciu określonych dowodów i argumentów.

ExecuteAssembly(String, String[], Byte[], AssemblyHashAlgorithm)
Przestarzałe.

Wykonuje zestaw zawarty w określonym pliku przy użyciu określonych argumentów, wartości skrótu i algorytmu skrótu.

ExecuteAssembly(String, Evidence)
Przestarzałe.

Wykonuje zestaw zawarty w określonym pliku przy użyciu określonych dowodów.

ExecuteAssembly(String, String[])

Wykonuje zestaw zawarty w określonym pliku przy użyciu określonych argumentów.

ExecuteAssembly(String)

Wykonuje zestaw zawarty w określonym pliku.

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

Przestroga

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.

Wykonuje zestaw zawarty w określonym pliku przy użyciu określonych dowodów, argumentów, wartości skrótu i algorytmu skrótu.

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

Parametry

assemblyFile
String

Nazwa pliku, który zawiera zestaw do wykonania.

assemblySecurity
Evidence

Dostarczone dowody na zgromadzenie.

args
String[]

Argumenty punktu wejścia w zestawie.

hashValue
Byte[]

Reprezentuje wartość obliczonego kodu skrótu.

hashAlgorithm
AssemblyHashAlgorithm

Reprezentuje algorytm skrótu używany przez manifest zestawu.

Zwraca

Wartość zwracana przez punkt wejścia w zestawie.

Atrybuty

Wyjątki

assemblyFile to null.

assemblyFile nie można odnaleźć.

assemblyFile nie jest prawidłowym zestawem dla aktualnie załadowanego środowiska uruchomieniowego.

Próba wykonania operacji w niezaładowanej domenie aplikacji.

Zestaw lub moduł został załadowany dwukrotnie z dwoma różnymi dowodami.

assemblySecurity nie nulljest . Jeśli starsze zasady CAS nie są włączone, assemblySecurity powinna mieć wartość null.

Określony zestaw nie ma punktu wejścia.

Przykłady

W poniższym przykładzie pokazano użycie jednego z przeciążeń ExecuteAssembly w dwóch różnych domenach.

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

Uwagi

Zestaw rozpoczyna wykonywanie w punkcie wejścia określonym w nagłówku .NET Framework.

Ta metoda nie tworzy nowego procesu ani domeny aplikacji oraz nie wykonuje metody punktu wejścia w nowym wątku.

Ta metoda ładuje zestawy przy użyciu LoadFile metody . Zestawy można również wykonywać przy użyciu ExecuteAssemblyByName metody , która ładuje zestawy przy użyciu Load metody .

Dotyczy

ExecuteAssembly(String, Evidence, String[])

Przestroga

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.

Wykonuje zestaw zawarty w określonym pliku przy użyciu określonych dowodów i argumentów.

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

Parametry

assemblyFile
String

Nazwa pliku, który zawiera zestaw do wykonania.

assemblySecurity
Evidence

Dostarczone dowody na zgromadzenie.

args
String[]

Argumenty punktu wejścia w zestawie.

Zwraca

Wartość zwracana przez punkt wejścia w zestawie.

Implementuje

Atrybuty

Wyjątki

assemblyFile to null.

assemblyFile nie można odnaleźć.

assemblyFile nie jest prawidłowym zestawem dla aktualnie załadowanego środowiska uruchomieniowego.

Próba wykonania operacji w niezaładowanej domenie aplikacji.

Zestaw lub moduł został załadowany dwukrotnie z dwoma różnymi dowodami.

assemblySecurity nie nulljest . Jeśli starsze zasady CAS nie są włączone, assemblySecurity powinna mieć wartość null.

Określony zestaw nie ma punktu wejścia.

Przykłady

W poniższym przykładzie pokazano użycie jednego z przeciążeń ExecuteAssembly w dwóch różnych domenach.

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

Uwagi

Zestaw rozpoczyna wykonywanie w punkcie wejścia określonym w nagłówku .NET Framework.

Ta metoda nie tworzy nowego procesu ani domeny aplikacji oraz nie wykonuje metody punktu wejścia w nowym wątku.

Ta metoda ładuje zestawy przy użyciu LoadFile metody . Zestawy można również wykonywać przy użyciu ExecuteAssemblyByName metody , która ładuje zestawy przy użyciu Load metody .

Dotyczy

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

Źródło:
AppDomain.cs
Źródło:
AppDomain.cs
Źródło:
AppDomain.cs

Przestroga

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

Wykonuje zestaw zawarty w określonym pliku przy użyciu określonych argumentów, wartości skrótu i algorytmu skrótu.

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

Parametry

assemblyFile
String

Nazwa pliku, który zawiera zestaw do wykonania.

args
String[]

Argumenty punktu wejścia w zestawie.

hashValue
Byte[]

Reprezentuje wartość obliczonego kodu skrótu.

hashAlgorithm
AssemblyHashAlgorithm

Reprezentuje algorytm skrótu używany przez manifest zestawu.

Zwraca

Wartość, która jest zwracana przez punkt wejścia w zestawie.

Atrybuty

Wyjątki

assemblyFile to null.

assemblyFile nie można odnaleźć.

assemblyFile nie jest prawidłowym zestawem dla aktualnie załadowanego środowiska uruchomieniowego.

Próba wykonania operacji w niezaładowanej domenie aplikacji.

Zestaw lub moduł został załadowany dwukrotnie z dwoma różnymi dowodami.

Określony zestaw nie ma punktu wejścia.

Przykłady

W poniższym przykładzie pokazano użycie jednego z przeciążeń ExecuteAssembly w dwóch różnych domenach.

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

Uwagi

Przestroga

Zabezpieczenia dostępu kodu (CAS) zostały uznane za przestarzałe we wszystkich wersjach .NET Framework i .NET. Najnowsze wersje platformy .NET nie honorują adnotacji CAS i generują błędy, jeśli są używane interfejsy API związane z usługą CAS. Deweloperzy powinni szukać alternatywnych sposobów wykonywania zadań zabezpieczeń.

Zestaw rozpoczyna wykonywanie w punkcie wejścia określonym w nagłówku .NET Framework.

Ta metoda nie tworzy nowego procesu ani domeny aplikacji oraz nie wykonuje metody punktu wejścia w nowym wątku.

Ta metoda ładuje zestawy przy użyciu LoadFile metody . Zestawy można również wykonywać przy użyciu ExecuteAssemblyByName metody , która ładuje zestawy przy użyciu Load metody .

Dotyczy

ExecuteAssembly(String, Evidence)

Przestroga

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.

Wykonuje zestaw zawarty w określonym pliku przy użyciu określonych dowodów.

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

Parametry

assemblyFile
String

Nazwa pliku, który zawiera zestaw do wykonania.

assemblySecurity
Evidence

Dowód ładowania zestawu.

Zwraca

Wartość zwracana przez punkt wejścia w zestawie.

Implementuje

Atrybuty

Wyjątki

assemblyFile to null.

assemblyFile nie można odnaleźć.

assemblyFile nie jest prawidłowym zestawem dla aktualnie załadowanego środowiska uruchomieniowego.

Próba wykonania operacji w niezaładowanej domenie aplikacji.

Zestaw lub moduł został załadowany dwukrotnie z dwoma różnymi dowodami.

Określony zestaw nie ma punktu wejścia.

Przykłady

W poniższym przykładzie pokazano użycie jednego z przeciążeń ExecuteAssembly w dwóch różnych domenach.

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

Uwagi

Zestaw rozpoczyna wykonywanie w punkcie wejścia określonym w nagłówku .NET Framework.

Metoda ExecuteAssembly nie tworzy nowego procesu ani domeny aplikacji i nie wykonuje metody punktu wejścia w nowym wątku.

Ta metoda ładuje zestawy przy użyciu LoadFile metody . Zestawy można również wykonywać przy użyciu ExecuteAssemblyByName metody , która ładuje zestawy przy użyciu Load metody .

Dotyczy

ExecuteAssembly(String, String[])

Źródło:
AppDomain.cs
Źródło:
AppDomain.cs
Źródło:
AppDomain.cs

Wykonuje zestaw zawarty w określonym pliku przy użyciu określonych argumentów.

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

Parametry

assemblyFile
String

Nazwa pliku, który zawiera zestaw do wykonania.

args
String[]

Argumenty punktu wejścia w zestawie.

Zwraca

Wartość, która jest zwracana przez punkt wejścia w zestawie.

Wyjątki

assemblyFile to null.

assemblyFile nie można odnaleźć.

assemblyFile nie jest prawidłowym zestawem dla aktualnie załadowanego środowiska uruchomieniowego.

Próba wykonania operacji w niezaładowanej domenie aplikacji.

Zestaw lub moduł został załadowany dwukrotnie z dwoma różnymi dowodami.

Określony zestaw nie ma punktu wejścia.

Przykłady

W poniższym przykładzie pokazano użycie jednego z przeciążeń ExecuteAssembly w dwóch różnych domenach.

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

Uwagi

Zestaw rozpoczyna wykonywanie w punkcie wejścia określonym w nagłówku .NET Framework.

Ta metoda nie tworzy nowego procesu ani domeny aplikacji oraz nie wykonuje metody punktu wejścia w nowym wątku.

Ta metoda ładuje zestawy przy użyciu LoadFile metody . Zestawy można również wykonywać przy użyciu ExecuteAssemblyByName metody , która ładuje zestawy przy użyciu Load metody .

Dotyczy

ExecuteAssembly(String)

Źródło:
AppDomain.cs
Źródło:
AppDomain.cs
Źródło:
AppDomain.cs

Wykonuje zestaw zawarty w określonym pliku.

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

Parametry

assemblyFile
String

Nazwa pliku, który zawiera zestaw do wykonania.

Zwraca

Wartość zwracana przez punkt wejścia w zestawie.

Implementuje

Wyjątki

assemblyFile to null.

assemblyFile nie można odnaleźć.

assemblyFile nie jest prawidłowym zestawem aktualnie załadowanego środowiska uruchomieniowego.

Próba wykonania operacji w niezaładowanej domenie aplikacji.

Zestaw lub moduł został załadowany dwukrotnie z dwoma różnymi dowodami.

Określony zestaw nie ma punktu wejścia.

Przykłady

W poniższym przykładzie pokazano użycie jednego z przeciążeń ExecuteAssembly w dwóch różnych domenach.

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

Uwagi

Zestaw rozpoczyna wykonywanie w punkcie wejścia określonym w nagłówku .NET Framework.

Ta metoda nie tworzy nowego procesu ani domeny aplikacji oraz nie wykonuje metody punktu wejścia w nowym wątku.

Ta metoda ładuje zestawy przy użyciu LoadFile metody . Zestawy można również wykonywać przy użyciu ExecuteAssemblyByName metody , która ładuje zestawy przy użyciu Load metody .

Aby utworzyć element do załadowania AppDomain i wykonania, użyj CreateDomain metody .

Dotyczy