-1

I currently work on a HUGE C++/CLI/C# application. At some point during the runtime (not at startup) this application loads a certain .NET assembly.

By using the Modules Window in Visual Studio I can see that the assembly is initially not loaded. After some time the assembly appears in the Modules Window.

Is there an easy way to find out where/why/when the assembly has been loaded? Ideally I would like to set some sort of breakpoint, that fires when this specific assembly is being loaded. So that the application pauses and I get a proper call stack.

Is this possible without instrumenting the code (too much)?

Jack J Jun
  • 5,633
  • 1
  • 9
  • 27
Boris
  • 8,551
  • 25
  • 67
  • 120
  • It depends if the assembly is external, if the assembly is loaded by raw bytes then it's going to be hard for you to detect that. – Vinnywoo Oct 16 '20 at 13:19
  • 1
    Does this answer your question? [How do I determine the dependencies of a .NET application?](https://stackoverflow.com/questions/227886/how-do-i-determine-the-dependencies-of-a-net-application) – Murray Foxcroft Oct 16 '20 at 13:24
  • [AppDomain::AssemblyLoad event](https://learn.microsoft.com/en-us/dotnet/api/system.appdomain.assemblyload). You won't necessarily get much out of a stack trace, assemblies are loaded when the just-in-time compiler needs them, before the code starts running. – Hans Passant Oct 16 '20 at 14:43

1 Answers1

0

You can try my Runtime Flow tool to find it out.

For example, setting Monitoring filter to Module == MyAssembly.dll will show you the first method called in the assembly and adding more modules will show who called it.

Sergey Vlasov
  • 26,641
  • 3
  • 64
  • 66