In the garden, I saw an article about the. NET system and framework development, and it felt quite deep, as a. NET programmer, and found that their follow-up and understanding in this area is far from enough. Go to yourself and share it for later viewing.
Original link: http://www.cnblogs.com/sunhoy/p/6371178.html
Basic Concepts
. Net itself is a common development platform, my personal understanding of the main sub-level is as follows two levels: 1. Language level, 2. Run-time
First: At the language level
There are a number of top-level development languages for the. NET platform, such as c#,f# and Visual Basic, and the. NET Framework provides the common language runtime used by these languages, regardless of the language of the runtime, which defines common specifications for these languages, such as type systems, file formats, and so on.
The code written in these high-level languages is called managed code that needs to be compiled into intermediate code (IL) by the compiler and then taken over by the common language runtime (CLR) and then JIT-compiled to give the machine code to run to the CPU.
The common language runtime automatically handles object layouts and manages object references, freeing them when objects are no longer being used. The object that implements lifetime management in this way is called managed data. Garbage collection eliminates memory leaks and other common programming errors.
Second: run-time plane
The current. NET runtime primarily has the. NET Framework, Mono for Xamarin and. NET Core. These runtimes in different times are mainly to solve the problems faced at that time derived from, here describes their mutual relevance and responsibility.
1. The. Net Framework, which has been in existence since 2002. NET runtime is also a framework that developers are often using today. Covers the desktop, web and other applications, including some Windows-specific APIs, but it can only run on the Windows platform constraints, to the requirements of the cross-system platform for the development requirements of high demand caused great difficulties, is very suitable for the development of desktop applications.
2. Mono for Xamarin, the one that was launched in 2004 by unofficial organizations in order to achieve. NET cross-system operation. NET runtime, which was primarily capable of supporting code written under the. NET Framework, runs under Linux and other systems, and currently includes APIs for IOS, Android, Xamarin.Forms, and Xamarin.mac. Mono for Xamarin is great for building IOS and Android mobile apps.
3.. Net Core This is Microsoft's official release. NET runtime, mainly in order to break the system limitations of the. NET Framework, to implement cross-operating system platform development, in a certain program is replacing the latter, the official definition of it is the ASP and Universal Windows Platform (UWP) used by the runtime. It's new, efficient, and designed to handle large-scale server and cloud workloads.
These three runtimes,. Net developers must have a sober understanding of the relationship between them, we understand the relationship between the runtime, we can continue to learn the relationship between the class library framework of the three
Introduction to cross-frame development
The above is mainly about the current. NET platform's base information, and because of the different system support, in different runtime support framework will have its own different features. In particular, when the. Net Core Matures, the need for cross-framework support for old and new projects is growing, how to share across framework class libraries, and how old projects can scale up support is an issue that has to be faced.
How to cross-frame development, Microsoft in this issue has given two solutions, one is to create a multi-objective. NET core project, the second is to create a portable class library (portable) or standard library (. NET standards), the first way of implementation I will explain in the implementation below, Here we introduce the second way, the two are the same purpose, but the scope and manner slightly different, where. Net standard is considered the best solution.
The official interpretation of. NET standards is that the. NET Standard library is a formal set of. NET API specifications that is expected to be rolled out in all. NET runtimes. The motivation to launch a standard library is to build greater uniformity in the. NET ecosystem. ECMA 335 continues to unify the. NET runtime behavior, but there is no similar specification for the. NET Base Class library (BCL) that is implemented for. NET libraries.
Its main purpose is to standardize the framework of the. NET runtime, and present a set of common API standards. Let's take a look at the current Microsoft Official framework and the current version of the detailed information:
That is, other frameworks can implement their own features, but also to implement the corresponding. NET Standard framework API, you can directly use the corresponding version of the. NET Standard Framework's class library in the Framework class library that is required. Below is a version control relationship for. NET Standard and other frameworks (called platforms in the figure):
If we need a new project that can support both the. NET core and the. NET Framework then we just need to create a new. NET Standard class library in VS 2017, and if you're using vs2015, you can create a new portable class library that corresponds to the English version: Class library (Portable)], and then switch to the. Net Standard Class Library under the Properties window.
Portable class library and standard library purposes are the same, mainly the impact of different, the new portable class library will let you choose the corresponding framework, the current class library implementation interface to take the intersection of the selected framework, and the standard library is independent of the specific framework, the corresponding version of the interface has been standardized.
Cross-framework development implementation
When you need to provide support for. NET core and framework for a single project, there are two scenarios where we can choose to directly build a. NET core multi-target project and build a portable class library or standard library.
1. Using a multi-target. NET Core project
The main scenario for using this approach is that certain projects must be supported by special features of the framework without the need to build two separate projects.
The benefit of this approach is that a single project can quickly compile different target version DLLs, and the disadvantage is that the current project may not be referenced directly in the same solution.
Implementation method:
A. Creating a new. NET Core project
B. Modify the Project.json file to add a version of the framework, such as:
C. For a specific target code, directly using conditional compilation symbols, here is the corresponding target version of the corresponding relationship, is also conditional compilation variable name:
. NET Framework 2.0-net20
. NET Framework 3.0-Net30
. NET Framework 3.5-Net35
. NET Framework 4.0-NET40
. NET Framework 4.5-net45
. NET Framework 4.5.1-net451
. NET Framework 4.5.2-net452
. NET Framework 4.6-net46
. NET Framework 4.6.1-net461
. NET Framework 4.6.2-net462
. NET Framework 4.6.3-net463
D. Compile build, can go to debug folder to view the corresponding target DLL
2. Using the standard library or portable class library, this is relatively simple, only vs2017 support directly create standard library projects, if you need to create a portable project in 2015, go to the property page to modify the target,
Above is my personal to the present. NET system, here is an official map of the complete platform:
(GO). NET infrastructure and cross-framework development