CLR build resolution at startup

Does the CLR [not necessarily download] check all dependent assemblies at program startup? That is, is dependent assembly allowed on demand? Note that I'm not talking about assembling an Assembly.Load * [reflective].

+4
source share
3 answers

This is a JIT compiler that directs the loading of assemblies in response to translating the IL into machine code. A method type call is first translated to call a stub function. When called, this stub activates the JIT compiler to load the IL (which loads the assembly, if necessary) and translates it. Very on request.

One wrinkle in this process is the assemblies that were executed through Ngen.exe, all .NET Framework assemblies were when they were installed on the machine. This is detected when the assembly is first loaded. The JIT compiler then skips the translation step and uses the previously translated machine code as is. Although this will load all the machine code generated by the assembly, it is still on request. The term "load" is relative here, Windows uses a memory-mapped file to map its own image to virtual memory space. No actual bytes are read from the file until the code arrives on a memory page that has not yet been mapped to RAM. The technical term for this is “page error,” as seen in Taskmgr.exe.

+4
source

A dependent assembly is permitted when the type that is defined in this assembly is required. Therefore, the assembly is loaded on demand.

+3
source

From here

Downloading and initializing the CLR bootloader as far as it can get away with. Unlike the Win32 bootloader, the CLR bootloader does not allow and automatically load slave modules (or assemblies). Rather, subordinate parts are loaded to require only if they are (as is the case with the Visual C ++ 6.0 load delay function). This not only speeds up the initialization of the program, but also reduces the amount of resources consumed by running the program.

+3
source

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


All Articles