When does the CLR load an assembly in a .NET process?

  • Is the .NET assembly loaded by the CLR when it references a class from the assembly?

or

  1. When does a class declaring namespace use from an assembly load?

Also, having loaded the assembly, does it ever unload the assembly if it has not been used for a long time?

+4
source share
3 answers

This is a JIT compiler that instructs the CLR to load an assembly as soon as it translates it into machine code that runs on demand and the exact time is not deterministic. Regarding the second question, as soon as the assembly is loaded into AppDomain, the only way to unload it is to destroy this AppDomain, there is no other way to unload the assembly.

+5
source

It loads when trying to use a type from an assembly. When the program receives a type that does not know about it, the runtime jumps and decides the type, which then loads the assembly that contains this type.

+1
source

Assemblies are loaded in various ways (links to the project, direct links - both of them at compile time (OK, apparently not)), but not using operators. As far as I know, they are never unloaded again.

0
source

Source: https://habr.com/ru/post/1306825/


All Articles