. NET Framework (revision)-Note (1)

Source: Internet
Author: User
Tags mscorlib

The book is divided into four parts and will be presented one by one. It feels good. If you are interested, you can buy it and check it out ~~

Part I Basic Principles of the Microsoft. NET Framework

 

Chapter 1 architecture of the Microsoft. NET Framework Development Platform

1.1 setSource codeCompile as a managed Module

The core of the. NET Framework is the common language runtime (CLR ).

The managed module generated by CLR is a standard Windows portable executable (PE) file that requires CLR execution.

Components of the hosting module:

① PE Header

② CLR header: record the location and size of information with little significance, such as version numbers and entry Methods

③ Metadata: Description SourceCodeTypes and members as well as referenced types and Members defined in

④ Intermediate language (IL) code: CRL compiles il into a local CPU command-also known as hosted code

1.2 combine managed modulesProgramSet

CLR does not deal with managed modules. It is directly oriented to assembly)

First, an assembly is one or more managed modules and a logical combination of some resource files. Second, the Assembly is the minimum unit for Component Reuse and implementation of security policies and version policies.

PE contains a data block called a list (manifest). It is only a set of other metadata tables. Describes the file that makes up the Assembly. The Assembly searches for a common export type implemented in the file, as well as some assembly-related resource files or data files.

1.3 loading general language runtime

1.4 run the Assembly Code

1.4.1il and code verification

Il is a stack-based language; Il commands are of no type. When il code is compiled as a local CPU command, CLR will execute a process called verification to ensure that everything done by Il is "safe. If it is not safe, a system. Security. verificationexception exception will be thrown.

1.5.net framework class library

. NET Framework class library (FCL) Assembly

P.22 Page 1.2 some common FCL namespaces are extremely useful

P.24 table 1.3 some FCL namespaces used for specific applications

1.6 Common Type System (CTS) is used to describe the type definition and behavior.

CTS is responsible for specifying that a type can contain 0 to multiple members: fields, methods, attributes, events, access modifiers, inheritance, virtual functions, object survival, and so on.

1.7 Common Language Specification (CLS) describes in detail a minimum set of features that must be supported by CLR-oriented compilers for Compiler vendors.

1.8 interoperability with unmanaged code

CLR supports three types of interoperability: ① hosting code calls the unmanaged functions in the DLL;

② Use the existing COM component for hosting Code (the unmanaged component serves as the COM server)

③ Unmanaged code uses the managed type (the managed type is used as the COM server)

Chapter 2 generate, package, deploy and manage applications

2.1.net framework deployment target

2.2 generate a type into a module-use the vs2005 Command Prompt

Csc.exe/out: app.exe/T: EXE/R: mscorlib. dll app. CS

Csc.exe/out: app.exe (output to, add path)/T: EXE (compiled as EXE by default)/R: mscorlib. DLL (an external assembly to be searched) app. the first three items of CS (files to be compiled) are default and can be removed;/nostdlib does not reference the default assembly;/T: EXE console user interface (Cui) /t: winexe application and graphical user interface (graphical user interface, GUI for short)/T: Library DLL file/T: module does not include the PE file and extension of the list of original data tables. netmodule;

P.39 Table 2.1 Common Metadata definition table

P.40 tables 2.2 Common Metadata reference tables

Use of ildasm

View. The original information is displayed! View metadata

View statistics view information such as file size, header, and IL code

2.3 combine modules into an assembly

Assebmly is a set of one or more types of definition files and resource files. It is a CLR operation object.

Features: ① defines reusable types; ② identifies a version number; ③ it can contain related security information;

P.48 table 2.3 list metadata table

The list provides an indirect association between the user of the Assembly and each part of the Assembly, and also enables the Assembly to implement self-description.

/Addmodule loads the. netmodule file as part of this Assembly.

CLR loads the Assembly file of a type only when a method of the type is called.

2.3.1 use Visual Studio. Net ide To add Assembly references for the project

2.3.2 use Assembly Linker (Assembly linker, that is, al.exe)

You can generate an EXE or dll pe file that does not include any other content. The list is only used to describe the type in other modules. Al/out: Ming. dll/T: Library AAA. netmodule BBB. netmodule

2.3.3 include resource files in the Assembly

Use/embed [Resource] Or/link [Resource] In al.exe (resources are not compiled, and resource files must be carried in the directory of the EXE file at the same level at any time)

Use/resource or/linkresource in csc.exe is similar to/Link

/Win32res embed Win32 resource file. Res

/Embed win32icon into the ICO File

2.4 assembly version Resource Information

Right-click version information under the version Tab

Class usage features such as [Assembly: assemblyversion ("1.0.0.0")], see p.57

Al.exe command line switch see P.58-59 Table 2.4 command line switch and custom features

2.4.1 version

The main version number, the version number, the generated version number, and the revised version number are separated. You can design the version by yourself.

2.5 Language and Culture

An assembly without a specified language culture is called a culture neutral assembly.

Al.exe command line/C [ulture]

Feature [Assembly: assemblyculture ("ZH-CN")]

2.6 simple application deployment (Private deployment Assembly)

The Assembly deployed in the same directory as the application is called the private deployment assembly (privately deployed assembly)

These assemblies are not shared by other applications (unless the application is also in the same directory)

Deployment method: simply copy to the base Directory of an application, the CLR can load and execute them.

Uninstall method: Delete the assembly in the directory or directory.

2.7 simple management control (configuration)

Config configuration file

You can use the class in the system. Configuration namespace in the program to configure the file at runtime.

Control Panel à management tool à Microsoft. NET Framework configuration machine. config file

Chapter 3 shared assembly

3.1 Two Types of Assembly and two deployment methods

Weakly named assembly and strongrong named Assembly have a publisher's public/private key pair signature, uniquely identifies the publisher of an assembly. Weak naming cannot be used for global deployment.

Top 3.2 named assembly

The four unique identity Assembly features: File Name (without extension), version number, Language and Culture identifier, and a public key.

Powerful naming utility (strong name utility, that is, sn.exe)

Generate a public/private key pair, Sn-K name. Keys; view Sn-P name. Keys name. publickey Sn-TP name. publickey

Create a strong Assembly. In the code, [Assembly: assemblykeyfile ("name. Keys")]

Default hashAlgorithmSHA-1 (secure hash algorithm, Security Hash Algorithm)

3.3 Global Assembly Cache

Global Assembly Cache (GAC), usually located in c: \ windows \ Assembly \ GAC

Save to gacuse gacutil.exe and run the program without the command line switch.

3.3.1gac Internal Structure

3.4 Reference a strongly-named assembly

The GAC directory is not found when csc.exe is referenced.

Use @ csc.exe @ AAA. rsp bbb. cs ccc. Cs in the response File

Anti-tampering feature of the top 3.5 named assembly

3.6 delayed signature (delayed signing)

Allow us to generate an Assembly only using the company's common key. The anti-tampering protection function will be lost.

The program uses the assemblykeyfileattribute and assemblydelaysignattribute features.

Al.exe uses/keyf [Ile] And/delay [sign] to implement

Run sn.exe-vr aaa. dll once during the test.

When preparing to package and deploy the application, retrieve the public/private key pair sn.exe-r AAA. dll aaw.vatekey. Keys

Test the recovery verification process. sn.exe-vu AAA. dll

Visual Studio. NET automatically adds an assemblyinfo. CS to set the Assembly feature.

Private deployment of top 3.7 named assembly

Use the configuration file to configure the URL address of codebase for small-scale private deployment

3.8 concurrent execution

CLR can load multiple files with the same name but different paths to the same address space, which is executed in the. NET Framework in both side-by-side mode.

3.9how does CLR parse type references?

When CLR compiles the code in JIT Mode, it detects all referenced types and members, loads the Assembly that defines them (how can it not be loaded), and looks for the following: if no exception is found, an exception will be thrown.

① The same file; ② different files, the same assembly; ③ different files, different assembly;

3.10 Advanced Management Control (configuration)

3.10.1 publisher policy control

3.11 fix the wrong application

 

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.