In .NET is there a way to enable Assembly.Load tracing?

.net, assemblies

Solution

Get the AppDomain for your application and attach to the AssemblyLoad event.

Example (C#):

AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler(OnAssemblyLoad);

Problem

In .NET is there a way to enable Assembly.Load tracing? I know while running under the debugger it gives you a nice message like "Loaded 'assembly X'" but I want to get a log of the assembly loads of my running application outside the debugger, preferably intermingled with my Debug/Trace log messages. I'm tracing out various things in my application and I basically want to know what action triggered a particular assembly to be loaded.

Original source