01. Learn the CLR execution model of the. net clr basic series from a simple perspective. netclr
. From code generation to execution, some column processes in the middle are a new concept different from other new technologies. What kind of process is this? What kind of mechanism is there, we have understood these basic things. net. So what kind of process is the CLR execution model?
Compile the source code into a managed module --> combine the managed module into an assembly --> load the Common Language Runtime --> execute the Assembly Code
Directory
- Compile source code into a managed Module
- Merge managed modules into an assembly
- Loading public Language Runtime
- Code for executing the Assembly
- Local Code Generator: NGen.exe
- Framwork class library
- General Type System
- Common Language Specification (CLS)
- Interoperability with unmanaged code
Compile source code into a managed Module
First. net Development supports multi-language selection or mixed-language programming. code compilation adopts the CLR-oriented mechanism of the compiler, that is, the code written in whatever language, you only need to use the CLR-oriented compiler.
Common Language Runtime: Runtime, which can be used by multiple programming languages ". Core CLR functions (such as memory management, assembly loading, security, exception handling, and thread synchronization) can be used in all CLR-oriented languages.
Managed module: The Managed module, that is, the compiler compilation result is a Managed module.
IL: Each CLR-oriented compiler generates IL (intermediate language) code. It also becomes a hosting code, because CLR needs to manage its execution.
Native code compiler: local code compiler. Generates code for specific CPU architectures (X86, X64, and IA64.
Metadata: Metadata. It is a data table. Some of the Data describes the content defined in the module, such as the type and members, and some data describes the content referenced by the module, such as the import type and its members. Metadata is always associated with files containing IL Code and is always synchronized.
Merge managed modules into an assembly
Displays the process of merging managed modules into an assembly.
Assembly: logical grouping of one or more modules/resource files; assembly is the minimum unit for reuse, security, and version control.
From the display, we can see that assembly contains a data block named "manifest". It is another collection composed of metadata tables and describes the files that constitute the assembly.
Al.exe: Assembly connector in another region
Loading public Language Runtime
WindowsCheck the EXE file header:
PE32: 32-bit address space is required, which can be run in 32-bit/64-bit address space
PE32 +: 64-bit address space required
CPU architecture information to ensure that the current CPU meets the requirements
Create a 32/64/WoW64-bit process:Created based on the exe file header
Load MSCorEE. dll:This file is in C: \ Windows \ SysWow64 or C: \ Windwos \ Sys
The above process is clear.
Code for executing the Assembly
To execute a method, you must first convert its IL to the local CPU command. This is the responsibility of the clr jit (just-in-time or "instant") compiler. Always analyze the process.
Local Code Generator: NGen.exe
NGen.exe: A tool provided by. NET Framework. You can compile the IL code at a cost when an application is installed on the target computer.
NGen.exe finally works:
Location: similar to C: \ Windows \ Microsoft. NET \ Framework \ v4.0.30319
Command syntax:
Ngen <action> [options]
Ngen /? |/Help
Framework class library
FCL: Framework Class Library is a group of DLL Assembly collectively.
General Type System
CTS: Common Type System, which describes the Type definition and behavior.
Common Language specifications
CLS: Common Language Specification
I believe that mixed language programming forces Microsoft to develop CLS. CLS solves the problem that objects created in different languages can communicate with each other. To create a type that is easy to access from other languages, you can only select from your own programming language to determine which features are supported by other languages.
This requires that any compiler-generated type must support this minimum feature set to be compatible with components generated by other "CLS-compliant and CLR-oriented languages.
Tell the compiler the syntax to check CLS compatibility
[Assembly: CLSCompliant (true)]
Namespace SomeLibrary
{
}
Interoperability with unmanaged code
To cater to users of previously unmanaged code, Microsoft provides some mechanisms through CLR to allow applications to simultaneously include hosted and unmanaged code.
This article focuses on some architectural ideas and concepts of. NET platform design. We should have a basic understanding of. NET as a whole.
What is the difference between net clr 20507273634 and net clr 205072742?
2.0.50727.3634 is the version number.
The format of the version number is: Main version number. Minor version number. Build number. Revision number
2.0.50727.42 and 2.0.50727.3634 differ in the last one, with different revision numbers
. Net applications use CLR to explain the execution efficiency?
This problem exists. Because the. net program automatically executes security and memory management tasks at runtime, in order to ensure a high quality of operation, it sacrifices the performance, but it is not a problem of CLR performance.