Dieser Artikel wurde maschinell übersetzt. Wenn Sie die englische Version des Artikels anzeigen möchten, aktivieren Sie das Kontrollkästchen Englisch. Sie können den englischen Text auch in einem Popupfenster anzeigen, indem Sie den Mauszeiger über den Text bewegen.
Übersetzung
Englisch

AppDomain.AssemblyLoad-Ereignis

 

Veröffentlicht: Oktober 2016

Tritt beim Laden einer Assembly ein.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

public event AssemblyLoadEventHandler AssemblyLoad

The T:System.AssemblyLoadEventHandler delegate for this event indicates what assembly was loaded.

To register an event handler for this event, you must have the required permissions, or a T:System.Security.SecurityException is thrown.

For more information about handling events, see Handling and Raising Events.

The following sample demonstrates the E:System.AppDomain.AssemblyLoad event.

For this code example to run, you must provide the fully qualified assembly name. For information about how to obtain the fully qualified assembly name, see Assembly Names.

using System;
using System.Reflection;

class Test {

   public static void Main() {
      AppDomain currentDomain = AppDomain.CurrentDomain;
      currentDomain.AssemblyLoad += new AssemblyLoadEventHandler(MyAssemblyLoadEventHandler);

      PrintLoadedAssemblies(currentDomain);
      // Lists mscorlib and this assembly

      // You must supply a valid fully qualified assembly name here.      
      currentDomain.CreateInstance("System.Windows.Forms, Version, Culture, PublicKeyToken", "System.Windows.Forms.TextBox");
      // Loads System, System.Drawing, System.Windows.Forms

      PrintLoadedAssemblies(currentDomain);
      // Lists all five assemblies
   }

   static void PrintLoadedAssemblies(AppDomain domain) {
      Console.WriteLine("LOADED ASSEMBLIES:");
      foreach (Assembly a in domain.GetAssemblies()) {
         Console.WriteLine(a.FullName);
      }
      Console.WriteLine();
   }

   static void MyAssemblyLoadEventHandler(object sender, AssemblyLoadEventArgs args) {
      Console.WriteLine("ASSEMBLY LOADED: " + args.LoadedAssembly.FullName);
      Console.WriteLine();
   }
}

SecurityCriticalAttribute

Requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

.NET Framework
Verfügbar seit 1.1
Zurück zum Anfang
Anzeigen: