[C # advanced programming]. NET architecture,

Source: Internet
Author: User

[C # advanced programming]. NET architecture,

Content of this chapter:

Compile and run. NET-oriented code

Advantages of MSIL

Value Type and reference type

Data Type

Understanding error handling and features

Assembly,. NET base class, and namespace

This chapter mainly introduces some concepts with little content.

C # is a language specially designed for Microsoft's. NET Framework. It is an object-oriented method language.

C # is just a language. Although it is used to generate. net Framework Code, it is not a part of. net itself .. . Net does not support some features C #, and vice versa. For example, C # does not support Operator overloading. net does not.

The core of. NET Framework is its runtime execution environment, which is called the Common Language Runtime Library (CLR) or. NET Runtime Library. Generally, the code running under the control of CLR is called managed code)

Compilation process:

Compile the source code into MSIL (Microsoft Intermediate Language) and Microsoft Intermediate Language.

CLR compiles IL into platform-specific code

IL: a low-level language with simple syntax. It can be quickly converted to a local machine code, case sensitive, and stack-based language. Advantages: platform independence, improved performance and language interoperability.

Main features of IL:

Object-oriented and user interfaces

Significant differences between value types and reference types

Strong data type

Handle errors with exceptions

Features

CTS: A general type system. The code written in one programming language can communicate with the code written in another language. CTS describes the definition and behavior of the type.

CLS: a standard set of public language standards. Together with CTS, CLS ensures language interoperability.

GC: The Garbage Collector is used to manage memory in. NET, especially to restore the memory required by running applications.

Application domains are an important technical improvement in. NET and a method for separating components to reduce the system overhead of running applications.

Assembly: contains compiled code logic units for. NET Framework and can be stored in multiple files.

The executable code and library code use the same assembly structure. The only difference is that the executable Assembly contains a main program entry, but the library does not.

An important feature of an assembly is that the metadata they contain describes the types and methods defined in the corresponding code. An assembly also contains metadata that describes the Assembly itself.

Private assembly is the simplest assembly type. It is usually attached to a software and can only be used for the software. Because private assembly is completely self-contained, the process of deploying it is very simple. You only need to put the corresponding file in the corresponding folder of the file system (registry entry is not required ), this process is called "xcopy installation ".

Shared assembly is a public library that can be used by other applications. Because other software can access Shared assembly, some protection measures need to be taken to prevent name conflicts and version overwrite risks.

The solution is to place the shared assembly in a specific subdirectory tree of the file system, called GAC (Global Assembly Cache ).

To avoid name conflicts, specify a name for the shared Assembly according to the private key encryption method (for private assembly, you only need to specify the same name as the main file name). This name is a strong name, to ensure its uniqueness, it must be referenced by the application that wants to reference the shared assembly.

Issues related to version coverage risks can be solved by specifying version information in the assembly list, or by simultaneous installation.

The Assembly stores metadata, including all types defined in the Assembly and members of these types, so it can be programmed to access the data. This technology is called reflection.

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.