[C # advanced series] 02 generate, package, deploy, and manage applications and types-the Hello world,

Source: Internet
Author: User

[C # advanced series] 02 generate, package, deploy, and manage applications and types-the Hello world,

Okay, this image is still the same as Hello world.

In this chapter, many of them are about command line compilation and configuration items of some ghosts. You can directly use Baidu or look back at the books when using this document,

So you just need to know about it, and we didn't record it. Next we will talk about something that I think is useful.

References

Please see, there is a reference under the MyTest assembly, and everyone knows that there are many dll in the reference, and our source code only has the five using to reference the specific namespace in a dll.

(Referencing these dll will only have a slight impact on the compiler and will not affect the final generated file, nor affect the final performance)

That is to say, no matter how many dll files you reference, your source code only uses the five using files, then only those dll files containing the five using files will be referenced in the end.

Let's talk about PE files, assembly, and hosting modules,Metadata

Previously we talked about hosting PE files (I .e. those exe, dll), which includes four parts: PE Header, CLR header, metadata and IL code.

The PE Header is the standard information required by windows. The CLR header is unique to the hosting module, including the CLR version number, module entry method, digital signature, and the size and offset of the metadata table in the module.

 

 

MetadataIt is a binary block consisting of several tables. There are three metadata tables: a definition table, a reference table, and a list table.

 

The so-called definition table mainly refers to the description of some internal attributes and methods of this module.

 

The reference table describes the attributes and methods of the referenced assembly.

 

The so-called List table mainly refers to the information of the part of the file composed of the Assembly.

 

 

AssemblyIs the basic unit for reuse, version control, and application security settings. Data Types and resource files can be divided into separate files. (The fewer assemblies the program needs to load, the better the performance, because it helps reduce the working set and ease process space address fragmentation)

The CLR operation is an assembly. First, the file containing the list metadata table is loaded, and then the name of other files in the Assembly is obtained based on the list.

 

Well, we should focus on the relationship between the above four persons.

In combination with the Hello world Program, let's take a look at my own understanding:

The source code will generate a hosted PE file, also called a hosting module, which is the dll and exe. A hosting module contains the PE Header, CLR header, metadata definition table, metadata reference table, and IL code.

These managed modules and some images and other resource files, coupled with a metadata List table, are combined into an assembly (assembly is a logical concept ).

A pe file can only be a managed module or an assembly. The key to distinguishing whether a PE file is a managed module or an assembly is to check whether it has a metadata List table.

In the most common sense, a.exerefers to B .dll, and a.exe is an assembly, but B. dll references c. dll, so B. dll is actually an assembly.

At the same time, a, B, and c are both hosted PE files and managed modules.

 

I may have spared some trouble. If some of the above understandings are missing, I hope the great gods will point out that I will not go farther and farther on the wrong road.

 

Related Article

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.