The. NET Framework consists of the Common Language Runtime (CLR) and. NET Framework class libraries.
The core of. NET Framework is the execution environment of its Runtime Library, which is called the Common Language Runtime Library (CLR) or. NET Runtime Library. It can be seen as a proxy for managing code during execution. It provides memory management, thread management,
And remote management and other core services, and also enforce strict type security and other forms of code accuracy that can improve security and reliability.
Code management can be divided into two types based on whether the Runtime library is used: managed code and unmanaged code.
Another component of the. NET Framework is the class library, which is a comprehensive collection of reusable object-oriented types. You can use it to quickly develop multiple applications.
1. Common Language Runtime Library (CLR)
The Common Language Runtime Library (CLR) is the execution environment for hosting code and the core and basis of. NET Framework.
The code developed based on the Common Language Runtime Library (CLR) is called managed code, and the managed code must go through two compilation phases.
First, compile the source code into Microsoft intermediate language (msil), and then CLR compiles msil into platform-specific code.
The Common Language Runtime Library (CLR) provides a secure memory management mechanism. It automatically handles object la S and manages object references. It releases objects when they are no longer used. The objects that achieve lifetime management in this way are called managed data. Garbage collection eliminates memory leaks and some other common programming errors. Therefore, programmers do not have to worry too much about how to safely allocate and use the memory.
Msil uses the real-time (JIT) compiler to program code on a specific platform. JIT must verify the code before compiling the code into the local code, unless the Administrator has established a security policy that allows the code to skip verification. The verification process is mainly responsible for checking msil and metadata to determine whether the code is type-safe. This means that it can only access the memory location that has been authorized to access.
So the Runtime Library determines whether the code is type-safe?
First, the reference to the type must be strictly compatible with the referenced type. Second, only the correctly defined operations are called on the object. Again, it indicates that it is consistent with the claim.
The garbage collector (GC) completes memory management in the. NET program. Memory Management is divided into memory allocation and memory release.
Ii. Assembly
An assembly is a collection of types and resources generated for collaborative work. These types and resources constitute a logical functional unit.
The Assembly provides the CLR with the information required for implementation. For CLR, the type must be in the Assembly context.
An assembly is a block generated by. NET Framework applications. An assembly constitutes the basic unit of deployment, version control, reuse, activation range control, and security permissions. An assembly is a set of types and resources generated for collaborative work. These types and resources constitute a logical functional unit. The collection provides the information assembly for the Common Language Runtime Library to identify type implementations. It aims to simplify application deployment and solve possible version control problems in component-based applications. MS-help: // Ms. netframeworksdk. CHS/cpguidenf/html/cpconwhyuseassemblies.htm
The Assembly can be static or dynamic. Static assembly can include. NET Framework types (interfaces and classes), and the Assembly resources (bitmap, JPEG files, resource files, etc ). Static assembly is stored on the disk as a PE file. You can also use the. NET Framework to create a dynamic assembly. The dynamic assembly runs directly from the memory and is not stored on the disk before execution. You can save the dynamic assembly on the disk after it is executed.