C # Sharp experience-3. Basic Structure of the Microsoft. NET platform)

Source: Internet
Author: User
Tags net xml

Third, the basic structure of the Microsoft. NET platform

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

 

Index


C # Sharp experience

"Hello, world! "Program

C # BASIC Language Introduction

Basic Structure of Microsoft. NET platform

Class and Object

Constructor and destructor

Method

Domain and attribute

Indexer and operator overload

Array and string

Features and ing

Com interoperability with unmanaged programming and Exception Handling

Use C # to weave the future -- C # programming model Overview

It is meaningless to talk about C # On the Microsoft. NET platform. The "sharp" of C # is also a powerful backend platform. Just sticking to the syntax layer cannot experience the sharpness of C #, C #ProgramMany secrets must rely on the Microsoft. NET platform for deep understanding and application. Microsoft. NET platform is a revolutionary new XML Web Intelligent computing service platform built on open interconnection network protocols and standards, using new tools and services to meet people's computing and communication needs. It allows applications to communicate with each other conveniently and quickly over the Internet without worrying about the operating system andProgramming Language.

Specifically, Microsoft. the net platform mainly includes two kernels: Common Language Runtime (CLR) and Microsoft.. NET Framework class library, which is Microsoft. NET platform provides underlying technical support. The general language runtime is based on the underlying service of the operating system and is the execution engine of the Microsoft. NET platform. The Microsoft. NET Framework includes a set of class libraries that can be used in any programming language to make it easier for programmers to build network-based applications and services. Many application templates provide advanced components and services for developing network applications and services. The vast Microsoft. NET platform cannot be clarified here. We will focus on the basic platform infrastructure that is vital to developing applications using C.

General Language Runtime (CLR)

The general language runtime is the foundation of the entire Microsoft. NET Framework. It provides a managedCodeExecution environment. It is actually a piece of proxy code residing in the memory, responsible for the code management of the application throughout the execution period, typical include: memory management, thread management, security management, remote Management, instant compilation, and mandatory code security type check. These can be called the lifeline of the Microsoft. NET Framework.

In fact, we can see that CLR acts as a proxy for some of the management functions of traditional operating systems. Code under CLR is called managed code, otherwise it is called unmanaged code. We can also regard CLR as a technical specification. No matter what language the program uses, as long as it can be compiled into Microsoft's intermediate language (msil), it can run with its support, this allows applications to be independent from languages. Currently, up to 20 or 30 CLR programming languages are supported. Microsoft intermediate language is the language of the PE file output by the compiler on the Microsoft. NET platform. It is the most complete language set on the Microsoft. NET platform and is very similar to the assembly language on a PC. The real-time compiler compiles binary code in the intermediate language at runtime. It provides underlying technical support for the Microsoft. NET platform in multiple languages. In addition, the Microsoft. Net instant compiler provides economical real-time compilation and installation compile Technology in special cases as needed.

CLR is designed to provide the first level of support for component-based programming directly in the application running environment. Just as you have added direct support for Windows, controls, graphics, and menus, added the underlying structure for message-based programming and added abstract content for device independence, CLR directly supports components (including attributes and events), objects, inheritance, polymorphism, and interfaces. Direct support for attributes and events makes component-based programming easier without special interfaces and proper design patterns. When a component is running, CLR is responsible for managing memory allocation, starting and stopping threads and processes, enhancing the security factor, and adjusting the ancillary configurations of other components involved in the component. Serialization supports operations on components stored on disks in multiple formats, including SOAP based on industry-standard XML. CLR provides a powerful and coordinated way to handle error conditions. Each module has built-in complete metadata, which means that functions such as dynamic creation and method calling are easier and safer. Ing even allows us to flexibly create and execute code. We can control the version of components used by the application, which makes the application more reliable. Component code is an intermediate language (IL) that is independent of the processor and easy to verify, rather than a specific machine language, which means that components can not only run on multiple computers, it can also ensure that components do not overwrite the memory they do not use, nor potentially cause system crashes. CLR determines appropriate trust to managed components based on factors such as sources from the Internet, enterprise LAN, and local machines, in this way, CLR limits their permissions to perform some sensitive operations, such as reading files and modifying the registry, based on their trust. The Common Type System (CTS) is used to perform strict security checks on code types, avoiding possible Type mismatch between different components. All programming in CLR is performed around components.

It is worth noting that CLR is usually hosted in other high-performance server applications, such as Internet Information Server (IIS) and Microsoft SQL Server. This allows us to fully utilize the security and efficiency advantages of the general language runtime to deploy our own business logic.

Memory Management

The biggest impact of CLR on programmers is its memory management function, so it is necessary to list it separately. It provides a high-performance garbage collection environment for applications. The garbage collector automatically tracks the objects of application operations, and programmers no longer need to deal with complex memory management. For some so-called experts who like loose programming at the bottom layer, automatic memory management is always the object they laugh. Indeed, the Automated memory manager designed for the general software environment will never be able to make it manually tailored to a specific program. However, the modern software industry is no longer a workshop job with hundreds of lines of code, and thousands of lines of code are frequently used.AlgorithmBut the manageability and maintainability of engineering code .. Net/C # not prepared for such workshop masters, but the C language is their special feature. In a Microsoft. NET hosting environment, CLR is responsible for processing the memory layout of objects, managing object references, and releasing memory that is no longer used by the system (automatic garbage collection ). This fundamentally solves the memory leakage and Invalid Memory Reference problems that have plagued software for a long time, greatly reducing the development burden of programmers and improving program robustness. In fact, we cannot find the language commands for memory operations or release in the hosting environment. It is worth noting that Microsoft. NET applications can use hosted data or unmanaged data, but CLR cannot determine hosted data or unmanaged data.

The garbage collector manages the allocation and release of. NET application memory. When a new object is created using the new operator, the garbage collector allocates memory resources for the object in the managed heap. As long as the memory space in the managed heap is available, the garbage collector allocates memory for each newly created object. When an application no longer holds a reference to an object, the garbage collector detects and releases the object. It is worth noting that the garbage collector does not immediately start to release when the object reference is invalid, but determines when to collect and what objects to collect based on certain algorithms. The memory resources of any machine are always limited. When the memory space in the managed heap is insufficient, the garbage collector starts the collection thread to release the system memory. The garbage collector determines the objects whose memory is released based on their survival time and the number of collection times of objects. From a macro perspective, we do not know the exact behavior of garbage collection, but Microsoft. the. NET Class Library provides some functions to control the garbage collection behavior. In some special cases, it is necessary to perform some limited operations.

The garbage collector does not mean that programmers can use it once and for all. If they are operating an object that encapsulates underlying operating system resources such as files, network connections, Windows handles, bitmaps, etc, we still need to release these unmanaged resources explicitly. This is described in detail in "lecture 5 constructor and destructor.

Microsoft. NET Framework class library

The Microsoft. NET Framework class library is a broad set of object-oriented reusable classes that provide various advanced components and services for applications. It frees programmers from the heavy programming details and focuses on the commercial logic of the program, providing various development support for the Application-whether it is a traditional command line program or a Windows graphical interface program, ASP, which is intended for the Next Generation Internet distributed computing platform.. Net or XML Web Service. The following is a summary of these components and services.

  • System Framework Service
    The service framework includes a set of base class libraries that developers want to exist in the standard language library, such as collections, input/output, strings, and data classes. In addition, the base class library provides access to operating system service images, networks, threads, globalization and encryption classes. The service framework also includes data access class libraries and development tools, such as debugging and profiling services.

     

  • Ado. NET Component
    ADO. NET provides data access services for network-based scalable applications and services. Ado. net not only supports traditional data access based on the connection pointer style, but also provides high-performance access support for connectionless data templates that are more suitable for returning data to client applications.

     

  • XML data component
    All data can be seen as XML, and developers can use XML to convert, transfer, and confirm any data. The system framework provides Level 1 Operation Support for XML data. The system also supports General conversion between ADO. NET data and XML data.

     

  • Windows form component
    The Windows form component provides developers with powerful windows application models and rich Windows user interfaces, including traditional ActiveX controls and new Windows XP interfaces, such as transparent, layered, and floating windows. Strong support for design is also an exciting part of the Windows form component.

     

  • ASP. NET application service
    The core of ASP. Net is a high-performance runtime language for processing low-level HTTP requests. The compilation and running mode greatly improves its performance. ASP. NET uses a component-based Microsoft. NET Framework preparation template. Therefore, it has advantages such as xcopy preparation, Component Parallel preparation, and XML-based preparation. It supports real-time updates of applications and provides high-speed buffer services to improve performance.

     

  • ASP. NET web forms
    ASP. NET web forms bring the highly productive advantages of VB-based forms to the development of network applications. ASP. net web forms support the traditional ASP syntax that combines HTML content with corner code, but it proposes a more structured method to separate application code from user interface content. ASP. NET provides a set of ASP. net web form controls and a more complex and powerful network application controls (such as calendar and ad board conversion ).

     

  • XML Web Service
    The ASP. NET application service architecture provides an advanced programmable template for creating XML Web Services Using ASP. NET. Although the creation of XML Web Services does not limit the use of specific service platforms, it provides many advantages to simplify the development process. With this programming model, developers do not even need to understand HTTP, soap, or any other network service specifications. ASP. net xml Web Service provides a simple, flexible, and industry-standard model for binding applications on the Internet using the existing architecture and applications.

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.