Search code examples
.netclrjit

How do managed applications run


I am learning .NET framework programming model.

When a managed exe is run(so no machine code in it),how does the CLR(mscorlib.dll) take over and do JIT compilation,or who calls the CLR or is it running all the time?


Solution

  • A managed executable still contains a standard Portable Executable (link)* header that contains information about :

    • what type of module it is,
    • the module creation time stamp,
    • CPU architecture (32/64),
    • entry point memory address of the _CorExeMain() (or _CorDLLMain()) function

    The PE header is read by windows when launching any application - in the case of a .NET application the header identifies it as a managed assembly and execution is then transferred to the CLR.


    *See : .NET, metadata, and the PE format section