So, what is the .NET Standard ?

So, what is the .NET Standard ?

We many times hear terms like .NET Framework, .NET Standard, .NET Core. Many of us understand what is difference between .NET Framework and .NET Core. But .NET Standard is something new to many of us.

In this article, let’s try to see what these three term means and how they are different from one another.

The World of .Net

Whenever you write any application which is in “.NET”, it can run on one or more implementations of .NET. There are multiple implementations of .NET framework, .NET Framework, .NET Core and Mono are some of them.

The .Net Standard specifies which all APIs should be available in any .NET implementation. The reason why .Net NET exists is to make sure that the implementations of .NET are uniform.

Let’s have a deeper look at the .Net Standard and .Net implementations.

The .NET Standard

Technically, the .NET Standard is a formal specification of .NET APIs that are intended to be available on all .Net implementations.  Every .Net implementation should ideally follow the .NET Standard so that there is a uniformity between different implementations. If there is uniformity in the implementation, the program compiled on one .NET implementation can easily run on the other .NET implementation.

There are three main important points to notice:

  • The .NET Standard defines uniform set of Base Class Libraries APIs for all .NET implementations to implement
  • The .NET Standard enables developers to produce portable libraries that are usable across .NET implementations.
  • The .NET Standard helps to reduces (or at least tries to eliminates) conditional compilation of shared source due to .NET APIs, only for OS APIs.

In Visual Studio, you can also target your applications to a specific version of .NET Standard. That way, you will be able to use only those APIs which are supported by the .NET Standard. The assemblies generated after build can be used with any .NET implementation which supports the .NET Standard.

The .NET Implementations

Every .NET implementation have more or less below components:

  • One or More Runtimes (e.g. CoreCLR for .NET Core, CLR for .NET)
  • Base Class Libraries. Some APIs from base class libraries follow the .NET Standard contracts. There may be additional APIs available depending on kind of platform (e.g. Windows, Linux, etc) the implementation is targeting.
  • Optionally, one or more application frameworks (e.g. WPF, Windows Forms are now part of both .NET Framework and .NET Core)
  • Optionally, development tools

Let’s have a quick look at some of the widely used .NET implementations and see how they are related to .NET Standard.

.NET Framework

This is the original .NET implementation which is available since 2002. The .NET Framework is supporting .NET Standard since .NET Framework 4.5. All framework versions after 4.5 support .NET standard and in addition they also have windows specific APIs and application frameworks (e.g. Windows Forms, WPF, etc).

As per comment in Microsoft documentation, .NET Framework will not support .NET Standard 2.1 or later versions. This decision has been taken in order to not break .NET Framework as there are enormous number of applications running on .NET Framework and they will get affected if any of the basic APIs are changed to support .NET .

.NET Core

The .NET Core is a cross platform implementation of .NET. The applications using .NET Core as target platform can run on Windows, Linux and MacOS. This implementation follows .NET Standard since its very first version.

Mono

Mono is the .NET implementation which is used when small runtime is required.  It is the runtime that powers Xamarin applications on Android, Mac, iOS, tvOS and watchOS and is focused primarily on a small footprint.  Mono powers the Game built using Unity.

Mono supports all published .NET Standard versions.

UWP – Universal Windows Platform

UWP is an implementation of .NET that is used for building modern, touch-enabled Windows applications and software for the Internet of Things (IoT). It’s designed to unify the different types of devices that you may want to target, including PCs, tablets, phablets, phones, and even the Xbox.

.NET : Standard vs. Implementations

The below image is taken from Microsoft documentation and provides high level overview of which .NET Standard version supports which version of .NET implementation.

.NET Standard

I hope this article helps you to clearly distinguish between the three terms – Framework, Core and Standard. Please comment and let me know your thoughts.