Reading Twitter and several discussion threads on GitHub or Reddit, I came to the conclusion that there still is a lot of confusion when discussing .NET Standard, .NET Core and .NET Framework. The truth is, .NET Core and .NET Standard are still new and Microsoft also keeps making some changes when releasing different versions that add to the confusion. That’s why I will try to demystify these different components of the .NET world. Before getting into it, I would like to underline that this is my understanding and therefore I might be wrong at some points, but overall I think the overall picture is still helpful for clearing some of the confusion out there.
A short history
Few years ago, everything was fairly simple. There was the .NET Framework which .NET developers could use to build different types of Windows applications and web applications running on IIS. Around 3 years ago Microsoft decided strategically to focus more on open source and cross-platform components and the release of .NET Core 1.0 was a first major step in this direction. The idea of building ASP.NET applications that could run both on IIS and on Linux was very appealing to developers and I think that this was a move into the right direction for Microsoft, but also for the .NET developers because of the potential reach .NET applications could have. This means more demand for .NET applications and more demand for .NET developers.
However, this huge strategic shift had some challenges mainly due to the monolithic appearance of the “old” .NET world and the diverse appearance of the “new world”. At the beginning the different new and old components of the .NET world were partially merging and there was maybe no clear paths towards important aspects like the development of class libraries for specific platforms or the portable class libraries to target different platforms at the same time. With the release of .NET Standard 2.0 and .NET Core 2.0 Microsoft defined a very clear way to think about the different .NET components and how to use them at their full potential. Starting with this point, .NET Standard, .NET Core, .NET Framework are fully different products, designed for specific requirements and scenarios.
.NET Standard, .NET Core, .NET Framework
I would like to start with the .NET Standard, because this component is in my opinion the foundation for all other components. The .NET Standard contains a set of APIs (serialization, networking, IO, collections and so on) that are shared throughout .NET Core, .NET Framework and Xamarin. So, the .NET Standard contains the base classes that all other components need to implement. You may check the complete list of the .NET Standard 2.0 APIs and compare it to the .NET Core APIs, you will see that .NET core simply implements all the .NET Standard APIs and adds only core specific APIs to them. You’ll notice the same thing if you also check the Xamarin APIs or the .NEt Framework APIs.
Why is this useful? Because if you want to create a class library that should work for .NET Core, .NET Framework and Xamarin together, you should target .NET Standard 2.0! You can create class libraries that target .NET Core, but those will work only in .NET Core applications. If you target the .NET Standard, the class will work fine in Windows Forms, WPF, UWP, Xamarin and APS.NET Core applications.
Conclusions: .NET Standard is an open source component containing a set of APIs that need to be implemented by all other .NET components.
.NET Core is an open source, cross platform development framework in the .NET world. It is primarily used to develop cross platform web applications that run both on Windows and Linux. It implements all the .NET Standard APIs and adds framework specific other APIs.
The .NET Framework is not open source and provides the necessary components to develop Windows specific applications and web applications running on IIS. It also implements the .NET Standard APIs and adds framework specific APIs to them. Within the .NET Framework you can develop Windows Forms, WPF applications and ASP.NET applications running on IIS.
Now, some confusion may arise, due to the fact that ASP.NET is both present in .NET Core and .NET Framework. Still, these are two different application models that run on totally independent frameworks. This is important to note, since if you build, for instance, a class library for an ASP.NET Core application and you expect to use it also on an ASP.NET application it won’t be possible! Remember if you would like to do this, you would need to target the .NET Standard with that specific class library and in this circumstance the class will still work with ASP.NET on the .NET Framework.
Here’s also a picture to summarize all these aspects:
- .NET Standard is one library to rule them all!
- .NET Core, .NET Framework and Xamarin are totally independent frameworks that implement the .NET Standard
- If you want to create a class library that spans all the frameworks, you should target the .NET Standard
- ASP.NET and ASP.NET core are application models specific for two different and independent frameworks, so you shouldn’t expect any out of the box portability between them.
I am aware that there are many other important discussion points, like porting existing portable class libraries (PCLs) to .NET Standard and so on, but I think it’s best to cover other aspects in different articles. Also, I count on your feedback using the comments section! Let me know if I might be wrong at some point, if you have any questions or suggestions. Till the next time!
How useful was this post?
Click on a star to rate it!
Average rating / 5. Vote count:
Latest posts by Dan Patrascu-Baba (see all)
- Configuration and environments in ASP.NET Core - 25/11/2019
- GraphQL in the .NET ecosystem - 19/11/2019
- A common use case of delegating handlers in ASP.NET API - 12/11/2019