Say, before the opening,
Very early to say metadata (metadata) and IL (intermediate language) ideas, has been in this beginning to be counted on the ground to these two class brothers cast some fine care, although there is no "first time: enmity: IS and as" so fast, But metadata and IL are absolutely heavyweight content that deserves our attention at any time, and this is the beginning.
1 Introduction
Have you ever thought about what our C # code is after compiling? Have you ever known what the trajectory of our executable program is when we run it? So, this paper begins with the understanding of metadata (metadata) and Il (Intermediate Language, intermediate language) to give the answer gradually. On this path of discovery, metadata, IL, assemblies, program fields, JIT, virtual dispatch, Method table, and managed heap these various mystery guests will encounter at some point, as you must know. NET As part of the Series 2.0, this article starts with the two heavyweight players who know the metadata and IL, and the other guests will soon be on the stage.
2 Initial Contact
In fact, the compiled CS code is organized into two basic elements: Meta data (Metadata) and IL. The simplest way to understand the secrets of metadata and IL contained in an assembly (*.dll) or executable (*.exe) is that we often say decompile, open the ILDASM, and load the assembly where the implementation is prepared, and we can see the contents of the managed PE file:
Detailed structure information and IL Code Analysis can be found in [you must know. NET] in the 3rd chapter, "Everything Starts with Il" Introduction, this does not do too much analysis. In addition, we can perform "view/metainfo/show!" or ctrl+m shortcut keys to get a list of the metadata information used by the assembly:
The metadata used by the assembly is mainly: Module, TypeRef, TypeDef, method, Param, MemberRef, Costomattribute, Assembly, AssemblyRef, etc. Strings, #GUID, #Blob, #US堆等.
Of course, there are a lot of fun ways to use the ILDASM tool to satisfy our curiosity to explore IL code, for example:
ILDASM anytao.insidenet.metadatail.exe/output:my.il, export the decompile result to the IL code format, generating a my.il containing all the IL code and a my.res containing all the resource files.
ILDASM Anytao.insidenet.metadatail.exe/text, outputs the decompile result as a console.
Of course, we recommend the GUI form to view the IL details, well-organized Class View:
ILDASM Anytao.Insidenet.MetadataIL.exe