What is .NET Standard and When to Use It?

Modern applications often need to be adapted to different types of devices and operating systems, and therefore to different implementations of .NET (.NET Framework, .NET Core and Xamarin). In this case the maintaining shared code becomes a challenge. You need to understand what APIs are available and make sure that common components only work with APIs that are supported in all .NET implementations you use. The .NET Standard was created to solve this problem. Each version of .NET Standard defines a set of APIs. All .NET implementations conforming to this version must support all of these APIs.

The table below shows which .NET implementations are suitable for which tasks:

PlatformOSIs Open SourceType of applications
.NET StandardAnyYesCreate libraries that can be used in any .NET implementation, including .NET Framework, .NET Core, and Xamarin.
.NET FrameworkWindowsNoCreate classic Windows and ASP.NET web applications for IIS.
.NET CoreWindows, Linux, macOSYesBuild cross-platform console apps as well as ASP.NET Core web apps and cloud services.
XamariniOS, Android, macOSYesCreate mobile apps for iOS and Android, desktop apps for macOS.

When to use .NET Standard? – Example

Let’s imagine you have an application that compares products from different sources. And your application is presented in the classic Windows Application, ASP.NET Core Web Application, and Xamarin mobile application. Obviously, these applications will have some common functionality like loading pricing, XML serialization, calculation, etc. For this purpose, you can create a shared library using the .NET Standard.

.NET Standard Versions

Each version of .NET Standard contains a certain set of APIs. Each new version of .NET Standard contains all the APIs of the previous versions and some new ones. This makes .NET Standard backwards compatible. You should remember two rules:

  • Higher version = More APIs
  • Lower version = more platforms

If you create a .NET Standard library that you want to share, you should always target the lowest version of .NET Standard that you can get away with. This way, you can reach the maximum amount of platforms.

.NET Standard 1.0 and Platform Support

.NET Standard 1.0
Click to open in a new tab

.NET Standard 1.1 and Platform Support

.NET Standard 1.1
Click to open in a new tab

.NET Standard 1.2 and Platform Support

.NET Standard 1.2
Click to open in a new tab

.NET Standard 1.3 and Platform Support

.NET Standard 1.3
Click to open in a new tab

.NET Standard 1.4 and Platform Support

.NET Standard 1.4
Click to open in a new tab

.NET Standard 1.5 and Platform Support

.NET Standard 1.5
Click to open in a new tab

.NET Standard 1.6 and Platform Support

.NET Standard 1.6
Click to open in a new tab

.NET Standard 2.0 and Platform Support

.NET Standard 2.0
Click to open in a new tab

.NET Standard 2.1 and Platform Support

.NET Standard 2.1
Click to open in a new tab

Leave a Comment