Reference, assembly, version, strong naming, Global File CLR learning lesson 3

Source: Internet
Author: User

I,CodeThe execution process of is the process of calling a method. When a method is dropped for the first time, the CLR checks the type referenced by the method, and then the CLR tries to load the referencedProgramSet list. If the type referenced by the method is exactly in this file, CLR will execute some internal bookkeeping work and then use this type. If the list shows that the reference type of the method is in another file, CLR will try to load these files, perform some bookkeeping work, and then start to use this type. CLR loads the assembly of a type only when a method of the type is called. It only means that an application does not need to run all the files in the referenced assembly.

Ii. Assembly Version Number Format: Main Board version number. Minor version number. version number generated. revision number. For example, in. net2.0, the version number of aspnet_isapi.dll is 2.0.50727.3053. You can find the EXE file or DLL file and view the version number, author, company, name, and many other information in the context menu. You can also view the version information in.

3. When the CLR needs to locate a file, it will scan several sub-directories of the application, first scan the current directory, and then scan down at the first level to scan the corresponding DLL file. When the DLL file scan ends, no assembly is found, and then the corresponding EXE file is scanned. If no, an exception is thrown, filenotfounexception.

4. Strongly-named assembly and weak-named assembly;

Weak naming assembly (Private deployment only): it can only be in the base directory or subdirectory of the current application. In the current project, if the assembly of the current project is not named and the Assembly is used externally in other projects, an error occurs. (The common keys without strong name signatures are displayed)

Strongly-named assembly can be deployed globally, that is, it can be referenced anywhere and copied to other project applications for normal use. A strongly-named assembly is added with a common key tag (Public Key/key pair) and is a unique name. Therefore, the same name will not be generated anywhere (because different companies may, in some cases, the generated Assembly name is the same, it will cause the file reference to be unknown; file Overwrite and other operations. This is why the weak naming Assembly can only be deployed privately. The strong naming Assembly successfully solves this problem, you can set a strong naming key file under "-- signature *" in project properties ). Purpose: The Assembly is not tampered.

5. GAC-Global Assembly Cache, which is located in the c: \ windows \ Assmbly folder. The purpose is to directly maintain a relationship in a strongly-named assembly and subdirectory. CLR has an internal function that accepts four parameters: Assembly name, version, language, and common key tag. Returns the path of the subdirectory where the specified Assembly file is located.

GAC-implements many application Assembly sharing, which reduces the overall use of physical memory. It is easy to add a new version of assembly to GAC as an administrator.

Each installer has a directory and a directory for storing shared assembly. When we install the installer in the directory, we also need to install an xml configuration file, and direct the codebase (actually a URL, local or network, and download the network) element of the shared assembly to its actual path, when the program runs, the CLR will know how to find the shared assembly in the directory of the strongly-named assembly.

Vi. Strong-naming Assembly tamper-proofing: when the Assembly is installed in the GAC directory, the system will perform hash conversion on the files containing the list, in addition, the hash conversion value is compared with the RSA Digital Signature embedded in the PE file (after the common key "anti-signature"). If it is different, the Assembly has been modified. The system will also perform hash conversion on other files of the Assembly, and then compare them with the hash values in filedef. If any mismatch is found, the Assembly will be tampered.

7. Delayed Signature: generate a company's common key (non-parameter Public Key/key pair) stored in the file.

8. CLR Execution Process: When we run an application, the CLR loads and starts it, then the CLR reads the CLR header of the Assembly to find the methoddeftoken of the main method of the application. According to the methoddef metadata table, CLR locates the offset of the Il code of the method, compiles the JIT method into local code, and completes the type security verification process of the Code, then execute the locally compiled code.

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.