4

Possible Duplicate:
How are DLLs loaded by the CLR?

I have noticed a strange but reasonable behaviour of the CLR, and was wondering whether or not this is a documented behaviour.

I have a method that looks similar to this:

public void SomeStuff()
{
     CreateDump();
     Logger.Info(this, "Created dump");
} 

I deleted the assembly that contains Logger class, and noticed that when SomeStuff is called, the assembly that contains Logger is attempted to be loaded.

I guess the CLR "plans ahead" a few instructions and tries to load the assembly beforehand?

When i refactored the call to Logger into a different method, it didn't demonstrate this behaviour.

Are there any rules on WHEN the actual assembly loading is attempted?

Community
  • 1
  • 1
lysergic-acid
  • 19,570
  • 21
  • 109
  • 218
  • Yeah, your answer is in the link bzlm provided. Basically the jit compiler will need to load any dependencies a method has before it can compile it to machine level instructions and run that method (doesn't work on an instruction by instruction basis due to those instructions being stored in ILASM and not machine assembler) – Jason Haley Jun 22 '11 at 01:28

0 Answers0