C # sharp experience third talker Microsoft.Net platform basic structure

xiaoxiao2021-03-06  100

Nanjing University of Posts and Telecommunications Li Jianzhong (Cornyfield@263.net)

Throwing the Microsoft.Net platform to talk about C # is meaningless, C # "Sharp" is also a powerful platform for its backend. It is only the sharpness of the grammatical level, and the C # process must rely on the Microsoft.Net platform to master and apply. Simply put, the Microsoft.Net platform is a revolutionary new XML web intelligent computing service platform that is based on open internet agreements and standards that adopt new tools and services to meet people's calculations and communications needs. It allows applications to communicate quickly and easily on the Internet without having to care about what operating systems and programming languages.

Specifically, the Microsoft .NET platform mainly includes two kernels, namely common language runtime, referred to as a Microsoft.NET framework library, providing underlying technology for Microsoft.NET platform implementation stand by. General Language Run is the most underlying service of the operating system, the execution engine for the Microsoft.Net platform. The Microsoft.NET framework includes a set of class libraries that can be used in any programming language that makes programmers easier to establish network-based applications and services. Above this is a lot of application templates that provide advanced components and services for developing network applications and services. The vastness of the Microsoft.Net platform is unique here, we will focus on the platform base constructs that we will experience the platform for us to use C # development applications.

General Language Run (CLR)

The entire microsoft .NET framework is based on the basis of the entire Microsoft.net framework, which provides a managed code execution environment for the Microsoft.Net application. It is actually a seven proxy code that resides in memory. The application is responsible for the code management work throughout the execution, relatively typical: memory management, thread management, security management, remote management, instant compilation, code forced security type. Check, etc. These can be called the lifeline of the Microsoft.NET framework.

In fact, we can see that the CLR proxy has part of the management function of the traditional operating system. The code under the CLR is called a managed code, otherwise it is called a non-hosting code. We can also view CLR as a technical specification, regardless of how the program is written, as long as it can be compiled into a Microsoft Intermediate Language (MSIL), you can run under its support, which makes the application to be independent of the language. It is currently supporting more than two thirty-three kinds of programming languages ​​in CLR. Microsoft Intermediate Language is the language of our PE files output by our compiler under the Microsoft.Net platform. It is the most complete language set of Microsoft.Net platform, which is very similar to assembly language on the PC. The instant compiler compiles the intermediate language to binary code at runtime. It provides a multilingual underlying technical support for the Microsoft.Net platform. In addition, the Microsoft.NET instant compiler provides compiler in special cases of instant compilation and installation technology.

The design purpose of the CLR is to provide first-class support for components directly in the application operating environment. Just as direct support for windows, controls, graphics, and menus in Windows, adding the underlying structure for messaging, which adds abstract content to support device-independence, and CLR directly supports components (including attributes and events). Objects, inheritance, polymorphisms and interfaces. Direct support for attributes and events makes components-based programming easier without requiring special interfaces and adaptation design patterns. When the component is running, the CLR is responsible for managing memory allocation, starting, and aborting threads and processes, strengthening the safety factor, and adjusts the accessory configuration of other components involved in the component. Serialization Support allows components stored on disk in a variety of formats, including SOAP based on industry standard XML. The CLR provides powerful and coordinated ways to handle errors. Each module has built-in complete metadata, which means that the functions such as dynamic creation and method calls are easier and safer. Mapping even allows us to flexibly create and execute code. We can control the version of the components used by the application, which makes the application more reliable. Component code is an intermediate language (IL) that is unrelated to the processor (IL) instead of a particular machine language, which means that components can not only run on multiple computers, but also ensure that components do not overwrite them. The memory used is not potentially caused by the system crash. The CLR determines the appropriate trust with the source of the managed component (eg, from the Internet, Enterprise Local LAN, Local Machine), which CLR will define them according to their trust, and modify the registry, etc. according to their trust. Some sensitive operations. A strict security check for code types is strictly securely inspected with a common type system (CTS) to avoid problems with mismatch between different components. The programming under the CLR is performed around the assembly. It is worth pointing out that CLR usually hosts in other high-performance server applications, such as the Internet Information Server (IIS), Microsoft SQL Server. This allows us to make full use of many security and efficient advantages of general language running to deploy their business logic.

Memory management

The CLR's most affected programmer is its memory management function, so it is necessary to list it separately. It provides a high-performance garbage collection environment for the application. The garbage collector automatically tracks the objects of the application operation, and the programmer has reused and complex memory management. This is the object that the automatic memory management has never laughed at some of the so-called masters that like to be obsessed. Indeed, automated memory manager designed for General Software Environment will never be used for hand-made itself for specific programs. However, the modern software industry is no longer a hundred lines of code workshop, and thousands of lines of code, a large number of commercial logic is no longer the integration of algorithms, but manageable, maintainable engineering Code. .NET / C # is not prepared for such workshop masters, C language is their essence. In the Microsoft.NET hosted environment, the CLR is responsible for handling the memory layout of the object, the reference to the management object, the release system is no longer used, and the automatic garbage collection). This fundamentally solves the problem of memory leakage and invalid memory reference issues for a long time, which greatly reduces the development burden of programmers and improves the robustness of the program. In fact, we can't find a language instruction for memory operations or releases under the managed environment. It is worth pointing out that the Microsoft.Net application can use managed data, or the non-hosting data can also be used, but the CLR does not determine the managed data and the non-hosting data.

The garbage collector is responsible for managing the allocation and release of the .NET application memory. When creating a new object with the New operator, the garbage collector assigns memory resources for the object in the managed heap. As long as the memory space in the hosted stack is available, the garbage collector allocates memory for each newly created object. The garbage collector will detect and release the object when the application does not hold a reference to an object. It is worth noting that the garbage collector does not immediately start release work when the object reference is invalid, but is based on a certain algorithm to collect and collect and collect any object. Any machine's memory resources are always limited. When the memory space in the hosted stack is not enough, the garbage collector starts the collection thread to release the system memory. The garbage collector determines the memory of which objects in accordance with the number of objects of the object, the number of objects that have passed through the object. Macro look, we don't know the exact behavior of garbage collection, but the Microsoft.Net class library provides us with some of the features that control garbage collection behaviors. In some special cases, we need some restricted operations. The garbage collector does not mean that the programmer can be once again for all. If you are working with an object that is packaged such as a file, a network connection, a Windows handle, a bit-level operating system resource, we still need to explicitly release these unmanaged resources. This has a detailed explanation in the "Fifth Tectors and Designors".

Microsoft.net framework class library

Microsoft.Net Framework Class libraries are a set of extensive, object-oriented reusable class, providing applications with a variety of advanced components and services. It liberates programmers from heavy programming details to focus on program business logic, providing various development support for applications - whether traditional command line procedures or Windows graphics interface programs, intended to distribute the next generation ASP.NET or XML web service for the platform. Below is an outline of these components and services.

转载请注明原文地址:https://www.9cbs.com/read-123739.html

New Post(0)