简体   繁体   中英

How is a compilation of a .NET Standard class library different than .NET Framework?

Compiling a .NET Standard project gives me a dll. .NET Standard projects can also have dependencies, so the code is being compiled into something. How is this different than what is compiled when a .NET Framework or .NET Core project.

Am I just "extending" the implementation of .NET Standard when I create a class library?

Everything I've read compares .NET Standard to an interface and .NET Core/.NET Framework to implementations of some version of those interfaces.

My question is, if that is true, how can I create an actual .NET Standard library. and why can't I reference a .NET Standard library that is using any version of .NET Standard (ex: .NET Framework 4.5 should be able to use a .NET Standard 2.0 class library since it is clearly already being compiled)?

As far as I understood it, when you compile against .NET Standard, you are effectively compiling against mockups, ie assemblies that contain the public interface that is defined by .NET Standard but no implementation. At runtime, these mockups are replaced by assemblies that contain type forwards to the actual implementation. The replacement works because the mockups and these type forwarding assemblies have the same signature. However, these type forwarding assemblies do not exist for every version of the .NET Framework, actually only for the very recent versions.

According to Microsoft`s definition:

.NET Standard is a set of APIs that all .NET platforms have to implement.

Note that, the .NET Standard is frozen. New APIs becomes available first in .NET Core or .NET Framework, and then after being review by a committee, the may be added in .NET Standard as well. Personally according to the above definition if I wanna develop a general library that I will use it during a product development lifecycle then I would prefer to make it more framework independent by using .NET Standard. More you can find here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM