Let's talk about the general usage of the C # naming line compiler. For example, to compile a program. CS file, we can write it like this:
Csc.exe/out: other options of program.exe are default. By default, console programs are generated.
Csc.exe/out: program.exe/T: winexe generate GUI Program
Csc.exe/out: program. dll/T: library to generate dynamic link library
Csc.exe/out: program.exe/T: winexe/R: mylib. dll
Metadata is a binary data block consisting of several tables. These tables are divided into three categories: Definition table, reference table, and list table. Common Metadata definition tables include moduledef, typedef, and methoddef. reference the meta-data table assemblyref, moduleref, typeref, and memberref. We can use ildasm to open an assembly and select: view | metadata | display! You can view the metadata information of an assembly.
The following describes the metadata of an assembly:
Typedef #1 (02000002)
Typdefname: Programs (02000002)
Flags: [public] [autolayout] [Class] [sealed] [ansiclass]
[Beforefieldinit] (00100101)
Extends: 01000001 [typeref] system. Object
Bytes ---------------------------------------------------------------------------------------------------
Method #1 (06000001) [entrypoint]
Methodname: Main (06000001)
Flags: [public] [static] [hidebysig] [reuseslot] (00000096)
RVA: 0x00002050
Implflags: [il] [managed] (00000000)
Callcnvntn: [Default]
Returntype: void
No arguments.
Bytes --------------------------------------------------------------------------------------------------------
Method #2 (06000002)
Methodname:. ctor (06000002)
Flags: [public] [hidebysig] [reuseslot] [specialname]
[Rtspecialname] [. ctor] (00001886)
RVA: 0x0000205c
Implflags: [il] [managed] (00000000)
Callcnvntn: [Default]
Hasthis
Returntype: void
No arguments.
Bytes --------------------------------------------------------------------------------------------------------------
Typeref #1 (01000001)
Token: 0x01000001
Resolutionscope: 0x23000001
Typerefname: system. Object
Bytes ------------------------------------------------------------------------------------------------------------
Memberref #1 (0a000004)
Member: (0a000004). ctor:
Callcnvntn: [Default]
Hasthis
Returntype: void
No arguments.
Bytes --------------------------------------------------------------------------------------------------------------
Typeref #2 (01000002)
Token: 0x01000002
Resolutionscope: 0x23000001
Typerefname: system. runtime. compilerservices. compilationrelaxationsattribute
Certificate -------------------------------------------------------------------------------------------------------------------------------------------
Memberref #1 (0a000001)
Member: (0a000001). ctor:
Callcnvntn: [Default]
Hasthis
Returntype: void
1 arguments
Argument #1: I4
Because the word description of the. NET assembly does not require special packaging, you can simply copy it directly. You can delete files directly when uninstalling them without leaving any garbage.
To implement the management control of an application, you can place an xmlconfig file named app.exe. config in the program directory. Note that the name cannot be changed at will, so you can write some basic configurations here.
<? XML version = "1.0"?>
<Configuration xmlns = "http://schemas.microsoft.com/.NetConfiguration/v2.0">
<Connectionstrings>
<! -- Vs automatically generated connection string. (1) -->
<Add name = "AAA" connectionstring = "Data Source = xxx; initial catalog = xxx; persist Security info = true; user id = xxx; Password = xxx" providername = "system. data. sqlclient "/>
</Connectionstrings>
<Deleetask>
<! -- Custom variable (2) -->
<Add key = "strconnection" value = "key1value"/>
<Add key = "name1" value = "key2value"/>
</Appsettings>
<System. Web>
<Compilation defaultlanguage = "VB" DEBUG = "true">
<! -- In a VB project, if the C # document (. CS) is located in the app_codecsharp directory
Add the following settings -->
<Codesubdirectories>
<Add directoryname = "CSHARP"/>
</Codesubdirectories>
...
</Compilation>
We know that. Net assembly has two deployment methods: Private deployment and co-deployment. The former is to put the Assembly in its own directory, and the latter installs the Assembly into the global buffer, that is, GAC. The public deployed assembly must be of a strong type. An Assembly contains four important attributes: a file name (without an extension), a version number, a language and culture, and a public key. The format is as follows:
"Mytypes, version = 1.0.8123.0, culture = neutral, publickeytoken = b77a5c561934e089"
"Mytypes, version = 1.0.8123.0, culture =" En-us ", publickeytoken = b77a5c561934e089"
"Mytypes, version = 2.0.1234.0, culture = neutral, publickeytoken = b77a5c561934e089"
"Mytypes, version = 1.0.8123.0, culture = neutral, publickeytoken = b03f5f7f11d50a3a"
The following figure shows how to sign an assembly:
If you want to deploy the tool to gac.exe, you cannot directly use the tool.
The following describes how a CLR uses metadata to locate and define a correct assembly of the type.
In short, the Configuration Policy of. Net assembly is very flexible, and you need to try it yourself.