C # differences between hosted and unmanaged programs

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.