This documentation is archived and is not being maintained.

AppDomain.AssemblyLoad Event

Occurs when an assembly is loaded.

[Visual Basic]
Public Overridable Event AssemblyLoad As AssemblyLoadEventHandler
public virtual event AssemblyLoadEventHandler AssemblyLoad;
public: virtual __event AssemblyLoadEventHandler* AssemblyLoad;

[JScript] In JScript, you can handle the events defined by a class, but you cannot define your own.

Event Data

The event handler receives an argument of type AssemblyLoadEventArgs containing data related to this event. The following AssemblyLoadEventArgs property provides information specific to this event.

Property Description
LoadedAssembly Gets an Assembly that represents the currently loaded assembly.


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

To register an event handler for this event, you must have the permissions described in the Permissions section. If you do not have the appropriate permissions, a SecurityException occurs.

For more information about handling events, see Consuming Events.


[Visual Basic, C#, C++] The following sample demonstrates the AssemblyLoad event.

[Visual Basic, C#, C++] 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.

[Visual Basic] 
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 

using System;
using System.Reflection;

class Test {

   public static void Main() {
      AppDomain currentDomain = AppDomain.CurrentDomain;
      currentDomain.AssemblyLoad += new AssemblyLoadEventHandler(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
   static void PrintLoadedAssemblies(AppDomain domain) {
      Console.WriteLine("LOADED ASSEMBLIES:");
      foreach (Assembly a in domain.GetAssemblies()) {
   static void MyAssemblyLoadEventHandler(object sender, AssemblyLoadEventArgs args) {
      Console.WriteLine("ASSEMBLY LOADED: " + args.LoadedAssembly.FullName);

#using <mscorlib.dll>

using namespace System;
using namespace System::Reflection;

__gc class Test {
   static void MyAssemblyLoadEventHandler(Object* sender, AssemblyLoadEventArgs* args) {
      Console::WriteLine(S"ASSEMBLY LOADED: {0}", args->LoadedAssembly->FullName);

void PrintLoadedAssemblies(AppDomain* domain) {
   Console::WriteLine(S"LOADED ASSEMBLIES:");
   System::Collections::IEnumerator* myEnum = domain->GetAssemblies()->GetEnumerator();
   while (myEnum->MoveNext()) {
      Assembly* a = __try_cast<Assembly*>(myEnum->Current);


int main() {
   AppDomain*  currentDomain = AppDomain::CurrentDomain;
   currentDomain->AssemblyLoad += new AssemblyLoadEventHandler(currentDomain, Test::MyAssemblyLoadEventHandler);

   // Lists mscorlib and this assembly

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

   // Lists all five assemblies

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard

See Also

AppDomain Class | AppDomain Members | System Namespace