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.