AppDomain.AssemblyLoad Event occurs when an assembly is loaded.
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
PrintLoadedAssemblies(currentDomain)
currentDomain.CreateInstance("System.Windows.Forms,Version,Culture,PublicKeyToken", "System.Windows.Forms.TextBox")
PrintLoadedAssemblies(currentDomain)
End Sub
Sub PrintLoadedAssemblies(domain As AppDomain)
Dim a As System.Reflection.Assembly
For Each a In domain.GetAssemblies()
Console.WriteLine(a.FullName)
Next a
End Sub
Sub MyAssemblyLoadEventHandler(sender As Object, args As AssemblyLoadEventArgs)
Console.WriteLine("ASSEMBLY LOADED: " + args.LoadedAssembly.FullName)
End Sub
End Module
Related examples in the same category