The Assemblies are loaded as soon as a method that references your assembly get's checked.
Roughly that is, when converting from IL to machine code. So as soon as your method references code in another assembly that assembly is loaded.
So in your example, the assembly that contains the RasDialer
class, will be loaded on the first time Main
is called, just before the executing of the method begins.
You should be aware that some small methods are inlined (but probably not while debugging). So code that is inlined, will load referenced assemblies as soon as it gets inlined.
void A(object arg0) {
if (argO == null) {
ClassFromAssembly1.Call();
B();
C();
}
}
void B() {
ClassFromAssembly2.Call();
}
[MethodImpl(MethodImplOptions.NoInlining)]
void C() {
ClassFromAssembly3.Call();
}
As soon as method A
is called for the first time, just before the code of method A
starts executing, both Assembly1 and probably also Assembly2 are loaded.
Assembly3 will be loaded, as soon as the first call to method C
is made.
The value of arg0
, cannot be used to control the loading of Assembly1. When Assembly2 will be loaded, cannot be determined (depends on the inlining of B). The loading of Assembly3 can be controlled with the value of arg0
.