NET Framework Operating principle

Source: Internet
Author: User


The core is the CLR (Common Language Runtime),

C # or any other language compiler principle: the original code through the relative compiler (syntax check the original code analysis) to generate IL code hosting (Il also known as managed code), and finally a managed module, one or more managed modules composed of assemblies (assembly) to the CLR to run;

The compiler needs to generate complete metadata for the managed module;
Metadata: is a collection of data tables that describes the reference types and members in a managed module, as well as some of their member types and definitions, with metadata and code embedded in the EXE or DLL;
Therefore, the compiler produces both the metadata and the IL code, and embeds them in the generated managed module;

The role of metadata in. NET:
Metadata eliminates the need for the source code to compile against the file and library files, and the compiler can take the metadata directly from the managed module to get the members and all the referenced types in the code;
Using metadata to help us write code, the IntelliSense feature of. NET is to provide an overview of what methods are provided by one of our types by analyzing the metadata, and the parameters of the method;
CLR code validation can use metadata to ensure security of execution;
The metadata garbage collector can track the lifetime of an object;

There are some managed modules and resource files in the assembly that, through the CLR processing, get the logical composition of all the files internally and get a list of data blocks that describe the files that make up the assembly; Note: The Assembly also contains some information about the other assemblies it references, which enables the Assembly to implement self-describing This also allows the CLR's execution to no longer be taken to the registry, so that the deployment of the assembly is much easier than the deployment of the unmanaged component;

Install VS08, which is primarily the CLR installation, and the CLR is responsible for managing code execution contained in the Assembly The mscoree.dll in the system file represents the native installed. NET Framework; As a result, we know that WinForm development has the. NET Framework requirements for host hosts, so be aware of adding when packaging the installation package. NETFramework as an accessory installation;


When an EXE assembly is generated, some special information is generated in the compilation, and the CLR uses this information to navigate to the application's entry point method when the assembly is loaded, to start the application, and note that if the unmanaged program calls the managed assembly, The entry function of the managed assembly DLL will also allow the CLR to handle the code contained therein;

Mscoree.dll is responsible for executing the assembly, indicating how to run the managed program under the. NET Framework.

C # is a high-level programming language, IL is a machine language, but different from the general machine language, it has a lot of advanced instructions, IL description should be said to be object-oriented machine language;
Il assembler ILAsm.exe disassembler ildasm.exe

Obfuscation Obfuscator, and for the protection of intellectual property one is to try to keep the managed programs and modules on the company server, the release of the need to rely on the obfuscation protection, in addition, if the obfuscation is not enough, only some sensitive algorithms can be implemented through unmanaged modules;

Introduction to the CLR
The largest feature allows for mixed integration of programming languages, C # 's I/O capability is prominent, and APL focuses on advanced engineering and financial calculations;
CLI (Development of common Language Infrastructure), CLI defines the file format, common type system, extensible metadata system, intermediate language and access to the bottom of the platform a total of five standards;

The CLR cannot execute the IL code directly, and the IL code needs to be converted to CPU instructions by a JIT-instant compiler;
The CLR works by detecting all the types referenced in the code, assigning an internal data structure to manage access to reference types, and when a method is called, the code is immediately compiled and converted to CPU instructions, and is dynamically stored in memory, so that a method can incur some performance damage only on the first call. Subsequent calls are no longer validated, and the command CPU executes at full speed.

Microsoft has done a lot of compression on performance, so the performance loss is negligible when the compiler transforms the first call;

FCL (. NET Framework Class Library assembly)

CTS (common type System) a formal specification of a type that describes the definition of methods, properties, and events, as well as the rules for type visibility and access to type members;
The CTS establishes a rule that takes an assembly as a type visibility boundary;

The IDE's integrated development environment (VS.NET) does not itself support multi-file assemblies (must be through command-line tools)

NET Framework Operating principle

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.