The MSIL code runs within the context of the CLR. The .text
section of the PE contains the instruction code JMP_CorExeMain that is defined
in the MSCorEE.dll file. This method reads the metadata information of the MSIL
code and compiles the MSIL code to native code at runtime. Finally, it executes
the main method. The Class Loader is responsible for reading the metadata
information, validating them for consistency and creating an internal
representation of the classes and its members. It is an object that is
responsible for loading classes at runtime. Internally, the CLR uses the
metadata and manifest information of an assembly for loading a class using the
Class Loader. It should be noted that the assembly, type and method references
are all resolved at runtime. Serge Lidin says in his renowned book Inside Microsoft.NET IL Assembler, "the loader reads
the metadata and creates in memory an internal representation and layout of the
classes and their members. It performs this task on demand, meaning that a
class is loaded and laid out only when it is referenced. Classes that are never
referenced are never loaded. When loading a class, the loader runs a series of
consistency checks of the related metadata."