Generally, the content of an executable file contains a PE Header. The system finds the entry function based on the PE information and executesCodeTo execute the executableProgram. The hosted program file also contains a CLR header file and other information required by CLR compared to the unmanaged program.
1. Execution Process of unmanaged programs
In an unmanaged program, the executable program saves the machine code, and the CPU can be directly loaded and executed. After the system loads the executable program, the system adds an offset address to the base address of the executable file to form the actual physical address and directly loads it into the memory for running.
2. Execution Process of the hosting program
The executable files of the managed program, including the intermediate language and metadata, cannot be run directly. The CLR must be started and the CLR can compile the machine code in real time for the intermediate language, and load it into the memory for execution (the specific process "The program jumps to mscoree before entering the entry function. DLL, call its code to start Clr and complete some initialization work ). Of course, the method in Il is not compiled every time it is called, but compiled only when it is called for the first time, real-time compilation stores the method name and corresponding entry in the ing table. When this method is called next time, it will be directly from the ing table instead of compiled again.