This documentation is archived and is not being maintained.

AppDomain.AssemblyLoad Event

Occurs when an assembly is loaded.

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

Public Event AssemblyLoad As AssemblyLoadEventHandler
Dim instance As AppDomain
Dim handler As AssemblyLoadEventHandler

AddHandler instance.AssemblyLoad, handler

/** @event */
public final void add_AssemblyLoad (AssemblyLoadEventHandler value)

/** @event */
public final void remove_AssemblyLoad (AssemblyLoadEventHandler value)

JScript supports the use of events, but not the declaration of new ones.

The 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 SecurityException is thrown.

For more information about handling events, see Consuming Events.

The following sample demonstrates the 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.

Option Strict On
Option Explicit On

Imports System
Imports System.Reflection

Module Test
   Sub Main()
      Dim currentDomain As AppDomain = AppDomain.CurrentDomain
      AddHandler currentDomain.AssemblyLoad, AddressOf MyAssemblyLoadEventHandler
      ' 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
      ' Lists all five assemblies
   End Sub 'Main
   Sub PrintLoadedAssemblies(domain As AppDomain)
      Console.WriteLine("LOADED ASSEMBLIES:")
      Dim a As System.Reflection.Assembly
      For Each a In domain.GetAssemblies()
      Next a
   End Sub 'PrintLoadedAssemblies
   Sub MyAssemblyLoadEventHandler(sender As Object, args As AssemblyLoadEventArgs)
      Console.WriteLine("ASSEMBLY LOADED: " + args.LoadedAssembly.FullName)
   End Sub 'MyAssemblyLoadEventHandler

End Module 'Test 

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0