Learn more about. Net framework


1、 CLR integrates many languages, and they can access each other because of the standard type set, metadata and common execution environment established by CLR.

Because there are great differences among different languages, such as case sensitivity, some don’t support unsigned, operator overloading or variable parameter methods, so if you want to create a program that can be accessed by other languages, your own programming language can only use those features supported by other languages.

To help us do this better, Microsoft defines a “common language specification (CLS)”.

2、 CTS defines a set of rules that language compilers must follow to define, reference, use, and store reference types and value types. Therefore, objects written in different languages following CTS can interact with each other. But not all types can be used in all languages.

3、 Language compiler: language compiler. Every language based on. Net has a CLR oriented managed module, which can also be understood as a language

Compiler, which compiles the corresponding language into MSIL.

MSIL: Microsoft intermediate language. CLR is responsible for compiling the intermediate language into a language that can be understood by the computer executing the program. It is a pseudo assembly language between high-level language and assembly language.

JIT (just in time compile): just in time compile, which interprets MSIL as a language that the program can understand.

4、 The execution model of CLR

1. The source code (VB, CS) is compiled into managed code block. Managed code block consists of intermediate language and metadata.

2. Merge managed code into an assembly, also known as a component (DLL). The assembly contains a module called “manifest”, which records the information that constitutes the assembly module, including resource files and the information that needs to refer to itself.

3. Load the common language runtime.

4. Code that executes the assembly.

5. Generate local code.

5、 CLI, common language infrastructure. CLI is a specification. CLR is an implementation of this specification.

6、 BCL, base class library

BCL is a common framework called base class library, which can be used by developers of all languages. It’s CIL (common language infrastructure, One of the specifications of common language infrastructure, which mainly includes: executing network operation, executing I / O operation, security management, text operation, database operation, XML operation, interacting with event log, tracing and some diagnostic operations, using unmanaged code, creating and calling dynamic code, etc. the granularity is relatively small, which provides basic support for all frameworks.

7、 FCL, framework class library

FCL provides a large granularity programming framework for different applications. Most implementations of FCL refer to BCL, such as the development framework

Frame: ASP.NET , MVC, WCF, WPF and so on, providing a framework for different levels.

8、 Managed and unmanaged code

1. Managed code is Visual.NET The managed code runs in the common language runtime (CLR).

2. Unmanaged code is the code that runs outside the common language runtime environment (CLR) and is executed directly by the operating system. Unmanaged code must provide its own garbage collection, type checking, security support and other services.


1. Managed code is an intermediate language that runs on CLR;

Unmanaged code is compiled into machine code and runs on the machine.

2. Managed code is independent of platform and language, which can better realize the compatibility between different language platforms;

Unmanaged code is platform and language dependent.

3. Managed code can enjoy the services provided by CLR (such as security detection, garbage collection, etc.), and does not need to complete these operations by itself;

Unmanaged code needs to provide its own security detection, garbage collection and other operations.

4. . net has many unmanaged resources, such as streamwriter, timer and database link.

9、 Unmanaged code unsaft

Unsaft can be used to modify classes, class member functions and class global variables, but it cannot be used to modify local variables in class member functions. In common language runtime (CLR), unsafe code is code whose value cannot be verified. Unsafe code in C # is not necessarily dangerous, just the code whose security cannot be verified by CLR. Therefore, the CLR only operates on unsafe code in a fully trusted assembly. If unsafe code is used, it is your responsibility to ensure that your code does not cause security risks or pointer errors. To run unsaft, you need to set:

1. Click the configuration properties folder.

2. Click the build property page.

3. Modify the allow unsafe code blocks property.

10、 Garbage collection GC

1. What is GC?

GC (garbage collector), as its name implies, is garbage collection. Here, only memory is concerned.

2. The working principle of GC is as follows

GC traverses all the objects dynamically allocated by the application on the heap, and determines which objects are dead and which still need to be used by identifying whether they are referenced. The objects that are no longer referenced by the application are dead objects, that is, the so-called garbage, which need to be recycled.

11、 There are two problems in the GC mechanism of. Net

1. First of all, GC doesn’t release all the resources. It does not automatically release unmanaged resources.

2. GC is not real-time, which will cause bottlenecks and uncertainties in system performance. Therefore, with the IDisposable interface, the IDisposable interface defines the dispose method, which is used by programmers to release unmanaged resources. Using the using statement can simplify resource management GC.Collect () method.

Function: force garbage collection.

12、 What is metadata?

Metadata is a kind of binary information, which is used to describe programs stored in common language runtime portable executable (PE) files or in memory

Metadata stores the following information: assembly description, type description, and properties.

13、 . net framework architecture

14、 . net framework concept review

1. IL / MSIL / CIL? Microsoft Intermediate Language) Microsoft Intermediate Language (IL is the abbreviation of MSIL, translated as intermediate language);

2. CTS (common type system)

3. CLS (common language specification) common language specification;

4. CLR (common language runtime) is the common language runtime (also called common language runtime);

5. JIT (just in time) compiler;

6. CLI common language infrastructure

7. Bcl – basic class library;

8. FCL framework class library;

The above is a simple understanding of the details of. Net framework. For more information about. Net framework, please pay attention to other related articles of developer!