. Net Basic Concepts

Source: Internet
Author: User

. Net Basic Concepts

1.. NET Framework

Is an internal Windows component that supports generating and running next-generation applications and XML Web services.. NET FrameworkThere are two main components:Common Language Runtime Library (Common Language Runtime)And. NET FrameworkClass Library (Framework Class Library).

2.Public Language Runtime Library) (Common Language Runtime)

Is the basis of. NET Framework. The runtime database can be viewed as a proxy for managing code during execution. It provides core services such as memory management, thread management, and remote processing, strict type security and other forms of code accuracy that can improve security and reliability are also enforced. In fact, the concept of code management is the basic principle of the Runtime Library.Code targeting the Runtime Library is called managed code, AndCode that does not target the Runtime Library is called unmanaged code. The following are the services provided by CLR:

Ø code management (loading and execution)

Ø application memory isolation

Type security verification

Convert IL to local code

Ø access to metadata (Enhanced type information)

Manage managed Object Memory

Enforce code access security

Ø exception handling, including inter-language exceptions

O mutual operations between hosted code, COM objects, and pre-existing DLL (unmanaged code and data)

Automation of object Layout

Support for developer services (analysis, debugging, etc)

3.. NET FrameworkFramework Class Library)

It is a comprehensive collection of object-oriented reusable types that can be used to develop a variety of applications, including traditional command line or graphical user interface (GUI) applications, it also includes ASP-based. NET provides the latest innovative applications (such as Web forms and XML Web services ). It can complete the vast majority of tasks previously completed through the Windows API.

4.Managed code(Managed code)

Code executed by the Common Language Runtime Library environment (rather than directly by the operating system. Hosted code applications can obtain the Common Language Runtime library service, such as automatic garbage collection, Runtime Library type check, and security support. These services help provide unified managed code application behavior independent of platform and language. Managed code has the following advantages:

Ø platform independence. The source code is first compiled into an intermediate language. during runtime, the CLR compiles the intermediate language into platform-specific code, which is the same as the byte code of Java, so that platform independence can be realized.

Improve performance. First, IL is more powerful than Java bytecode because IL is compiled in real time, while Java bytecode is often interpreted, converting to the platform executable code may cause performance loss. Second ,. NET real-Time Compiler (JIT) (Just In Time) does not compile all the code at once before execution, but only compiles the called part of the code, save the executable code. You do not need to re-compile the code next time you call it. Microsoft believes that this process is much more efficient than starting to compile the entire application code, because most of the code of any program is not actually executed during each running process. Finally, traditional compilers optimize the code, but their optimization process is independent of the specific processor that the code runs. For example, Visual Studio 6 optimizes a general Pentium machine, and the code generated by it cannot use the hardware features of the Pentium platinum processor. JIT has nothing to do with the platform, so it can be optimized for different machines.

Language interoperability. Interoperability is the ability to compile any language into intermediate code. compiled code can interact with the Code Compiled from other languages. The languages that can be interacted with in. NET include C #, VB. NET, Visual C ++. NET, Visual J #, script language, COM, and COM +.

5.Unmanaged code(Unmanaged Code)

Code that is directly executed by the operating system outside the public Language Runtime Library environment. The unmanaged code must provide its own services such as garbage collection, type check, and security support. Unlike the hosted code, the latter obtains these services from the public Language Runtime Library.

6.Intermediate Language (MSIL))

Intermediate Language (MSIL) plays an important role in. NET Framework. All. NET-oriented languages must be compiled into IL first, so they must logically support the main features of IL. MSIL is an intermediate process of converting. Net code into a machine language. It is a pseudo-assembly language between an advanced language and an Intel-based assembly language. When you compile a. Net Program, the compiler translates the source code into a group of commands that can effectively convert to Local Code and are independent of the CPU. When these commands are executed, the real-time (JIT) compiler converts them into CPU-specific code. Because the Common Language Runtime Library supports multiple real-time compilers, the same MSIL code can be compiled and run in different structures in real time by different compilers. Theoretically, MSIL will eliminate disputes between different languages in the industry over the years. In. in the world of Net, the following situations may occur: one part of the code can be implemented with Effil, and the other part of the code is completed using C # Or VB, however, the code will be converted to an intermediate language. This gives programmers great flexibility. programmers can choose the language they are familiar with, and no longer have to worry about learning new languages that are constantly being introduced.

7.CTS (Common Type System, general Type System)

A class is a way of expressing data. The basic data types defined by different programming languages are different. Since we need to implement "communication" between languages, we need a specification to implement the ing relationship between "different" data types (maybe only with different names but essentially the same. It is easy to use. Net Framework for interaction between various languages. CTS completes this task.

8.JIT (Just-In-Time)

From the full name, we can also see that the emphasis is on real-time, that is, when the intermediate code is executed in real time, the local computer code is compiled for different costs.

9.Assembly)

Is the smallest component unit of the. NET program. Each assembly has its own name, version, and other information. A collection is usually represented by a file (.exe or. dll). Such an assembly is called a single-file assembly, which is the most common. An assembly can also be composed of multiple files. Each file is a module file or a resource file. Such an assembly is called a multi-file assembly. The following describes how to generate a single-file assembly and a multi-file assembly.

10.PE (Portable and Executable Portable Executable) File

A pe file is a very important concept. It consists of the PE Header, CLR header, metadata, and IL (intermediate language) code.

Ø PE Header: mainly indicates the file type, GUI (graphical user), CUI (console), or DLL (in.. net dll is a form of Assembly file, different from the previous dynamic link library file ).
The header also contains a time mark used to indicate the time when the file was created. Most information about the header of a module that only contains the IL code is ignored. For modules that contain local CPU code,
This header also contains information about the local CPU code.

CLR header: contains information about the managed module (which can be parsed by CLR or some tools ). The information includes the CLR version number required by the managed module, some tags, and the entry points of the managed module.
Method (MethodDef) Metadata tag, as well as the location and size of metadata, resources, strong naming tags, and other information that is not significant.

[Metadata] (table): This table is used to describe the types and members used in the Code. There are two types of description and members. One is defined in the source code and the other is referenced. Metadata is always a file that contains IL code

In fact, metadata is always embedded into the same exe/dll file together with the code, and the compiler always generates metadata and IL code at the same time, and always embed them into the production hosting mode at the same time

Block, the two are always synchronized.
Use of metadata:
@ Metadata eliminates the need for source code compilation to generate first-class files and library files. This is because the IL code file containing implementation types and members already contains information about all referenced types and members,
The compiler can directly read the metadata from the managed module to obtain the information.
@ Intelliisense of Visual Studio. NET is implemented by analyzing metadata.
@ CLR the code verification process can use metadata to ensure that the Code only performs "safe" operations.
@ Using metadata, You Can serialize an object field and send it to a remote machine. Then, you can execute deserialization on the remote machine to recreate the object and its status.
@ Using metadata, the garbage collector can track the object's lifetime. For any object, the garbage collector can determine the object type through metadata, and can know which fields of the object are cited.
Other objects are used.

Ø IL code: the compiler compiles the commands generated by the source code, and the CLR compiles the CPU commands at the cost.

11.Managed module

The managed module is a Portable executable (PE) file that requires CLR execution.

Related Article

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.