Original: C # Learning Series-. NET Architecture
. NET Framework Overview
The. NET framework is. NET applications run to provide a virtual machine environment that provides compile, run, memory management, garbage collection, security, and other services for. NET applications.
?
. NET Framework Components
1. Common language Runtime (Common Language RUNTIME,CLR)
The 2.NET Framework class library (not all class library code in the. NET Framework is written in purely managed code, and a considerable number of classes in the. NET Framework are encapsulated in the Win32 API)
?
Managed code
Use. NET common language runtime, and vice versa for unmanaged code (such as the Win32 API)
?
Common Language Organization framework (CLI Common Language Infrastructure)
Specifies how types are declared, used, and managed in the runtime, as well as an important part of the runtime's support for cross-language interoperability
1. Build a framework that supports cross-language integration, type safety, and high-performance code execution
2. Provide an object-oriented model that supports the complete implementation of multiple programming languages
3. Define the rules that each language must follow to help ensure that objects written in different languages interact
?
Common language Runtime (CLR)
Responsible for management. NET application compilation, run, code type security checks, memory allocation, thread management, security, garbage collection, and other services to provide a virtual runtime environment for. NET Applications
?
Common type systems (CTS Common type System)
The CTS defines a type library, either VB or C #, whose data types are consistent, so. NET abstracts the data types of various programming languages, the CTS is born.
CTS types are mainly divided into: value types and reference types Http://wenku.baidu.com/link?url=LHBzlpJ8zHnLvsNzcmGxjpGgOolfq721gDvoVTY7gtNHTUbmhf_ Zv8z0glizecruyg020kqzhzetwvawstyqjzgxafodsmvva411vnacau7
?
Common Language Specification (CLS Common Language specification)
The CLS is a subset of the CTS, and the goal is to let. NET platform can be called between objects written in different programming languages
?
The CTS, CLR, and CLS relationships are as follows:
?
value type: stored in the memory stack, fast access, out of scope automatically frees memory, garbage collection mechanism does not participate in recycling.
Reference type: allocated in memory, the default NULL, the address of the memory allocated in the stack, the operation through the pointer to seek through the garbage collection mechanism to reclaim. When you assign the contents of a reference type variable to a variable of another reference type, only the memory address of the variable is copied.
?
Boxing : Converting a value type to a reference type int i=0; Object o=i;
unpacking : Converting a reference type to a value type int i=0;object o=i;int j= (int) o;
Packing and unpacking have an impact on performance loss.
?
Instant compile (JIT)
- At compile time: the CLR compiles C # code once, generating an intermediate code DLL or EXE.
- At run time, the CLR compiles the intermediate code into binary code and executes according to the hardware environment using JIT (immediate compilation engine).
- The compiled binary code is stored in a buffer cache, and the next call to the same code is made directly from the cache, meaning the same code is compiled only once.
?
NGEN (native Image Generator) compilation
The native Image Generator (Ngen.exe) is a tool for improving the performance of managed applications. Ngen.exe Create native images (files that contain compiled processor-specific machine code) and install them into the native image cache on the local computer. Instead of compiling the original assembly with the real-time compiler, the runtime can use the native image from the cache.
?
Intermediate language (MSIL is now called CIL Common Intermediate Language)
?
Refer to "c#4.0 authoritative guide"
C # Learning Series-. NET architecture