C # Preliminary Exploration of IL intermediate language in Via CLR

Source: Internet
Author: User
Tags mscorlib
First, we will write the simplest console app and print a line of characters:

Using system;

Using system. Collections. Generic;

Using system. text;
Namespace iltest

{

Class Program

{

Static void main (string [] ARGs)

{
Console. writeline ("test app for IL ");

}

}

}

After compilation is successful, an EXE file is obtained.
We use msil disassembler to open the extended PE format EXE file compiled by. net, and get metedata and Il.
Iltest. Program has three decompiling methods in ildasm, which are
// Method 1:
. Class private auto ANSI beforefieldinit iltest. Program
Extends [mscorlib] system. Object
{
} // End of class iltest. Program

// Method 2:
. Method public hidebysig specialname rtspecialname
Instance void. ctor () cel managed
{
// Code size 7 (0x7)
. Maxstack 8
Il_0000: ldarg.0
Il_0001: Call instance void [mscorlib] system. Object:. ctor ()
Il_0006: Ret
} // End of method program:. ctor

// Method 3:
. Method private hidebysig static void main (string [] ARGs) CIL managed
{
. Entrypoint
// Code size 13 (0xd)
. Maxstack 8
Il_0000: NOP
Il_0001: ldstr "test app for IL"
Il_0006: Call void [mscorlib] system. Console: writeline (string)
Il_000b: NOP
Il_000c: Ret
} // End of method program: Main

In addition, this pe32 file contains a "mainfest" data block. The list is another set composed of metadata tables. These table descriptions constituteProgramSet files. Types of public export implemented by files in the Assembly, and resources or data files associated with these assembly.

At the same time, a <project file name> .vshost.exe file with the same name as the project file is generated under the debug folder. this file is a host process that improves debugging performance. It supports partial trust debugging and expression computing during design.

In addition, it contains a PDB file with the same name, a program database file, and a file that stores the debugging and project status information. this allows you to incrementally link debugging configurations. the PDB file is created when C/C ++ programs are compiled by/Zi or visual basic/C # programs are compiled by/debug. for local machinesCodeIt resides in the \ debug subdirectory. For managed code, it resides in the \ windebug subdirectory.

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.