What is .NET Standard or .NET Standard Library?
Over the years .NET travelled a lot, There was a time when Applications are limited to .NET framework and server-desktop architecture only, but Mobile phones, smart devices played a huge role and bring evaluation in this field. .NET framework has upgrade itself to Xamarin platform and supporting cross platform development including UWP (Universal windows platform), Android and iOS, gradually .NET moved from Xamarin to .NET Core, A unique framework where cross operating system development is possible (development on Windows, MacOS, Linux). But is there some set of API exist that will support all these frameworks (I can say support to all .NET flavours) ? The answer is YES, We can use .NET Standard for it. Let’s see what is .NET Standard
What is .NET Standard?
.NET standard is the set of API that is available on all .NET implementations, It will create some type of uniformness, a portability that supports.Net Core, Xamarin and .Net Framework. Basically, It is the set of Base class libraries (BCL) that support a wide range of technologies like .NET Framework, .NET Core, MONO, Xamarin, Mac, Android, Universal Windows Platform, Windows Phone etc. The Base Class Library contains classes and basic libraries like exception handling, string, I/O, Network, data and collection.
Why we need .NET Standard
In last some years .NET extend its capability beyond windows operating system and platforms. It gets forked in .NET Framework, .NET Core and Xamarin, where some base libraries support them, These base libraries are built upon CLR that supported by Compiler and languages. See below image
Now, we can see .NET framework, .NET Core and Xamarin have its different base libraries that reside on CLR but here Developers needs to learn all these base libraries as there is no single platform to run and support these all. Take an example of .NET compact framework which was developed in the year of 2000’s to support phone but there is no common libraries exist for it, the same thing happen with mono. Due to this multiple .NET framework, developers need to take the support of different base libraries., Here .NET standard came in the picture. It just creates a common layer to access all these .NET flavours, see below image
We can see .NET standard library provide a common, uniform layer and set of API that supports all .NET flavours.
.NET standard is the alternative to PCL (portable class library).
Why PCL is not used for this task ?
There might question get up in mind that why the portable class library is not used for this task as it is already available in .NET. The answer is quite tricky, PCL support more API’s than platforms, here you need to re-compile application to support PCL, but as .NET standard support more platforms, In short, .NET standard fixes API than implement it so there is no need to re-compile application.
Now .NET let’s see the basic difference between .NET Framework Class Library VS .NET Core Class Library VS .NET Standard Class Library
.NET Framework Class Library
.NET framework class library has rich API support but it is only limited to its .NET framework, it means the Apps developed on .NET framework cannot be run on multiple platforms (like Smart Devices, Cross Operating like MacOS, Linux)
.NET Core library also has rich API support but here also it support only .NET Core apps but not to Android, Unity framework
So you should go with the .NET standard when you want to support more Apps (platform) and you are comfortable with limited API support, Here you will get limited API support but rich Apps support.
Here is the .NET standard version and compatibility list (Given by MSDN) :
|.NET Framework 1||4.5||4.5||4.5.1||4.6||4.6.1||4.6.1||4.6.1||4.6.1|
|Universal Windows Platform||10||10||10||10||10.0.16299||10.0.16299||10.0.16299||10.0.16299|
|Windows Phone Silverlight||8.0|
In above table .NET standard version and its supporting platforms are given. Where column header represent .NET standard version and first cell of each row represent the .NET implementation.
Now, let’s take an example
If you want to build a Apps that will support .NET framework V4.5, Windows, iOS, Android, Linux, Mono and UWP then you should go for .NET standard version 1.0.
One more example, suppose you want to build the application that support .NET framework 4.5(only) and .NET core 1.0 then you can use 1.0 or 1.1 .NET standard version
So here we can say that Less the .NET standard version, the more will be different platform support and vice versa
Microsoft has just release .NET Standard 2.0 which supports .NET Core 2.0, .NET Framework 4.6.1 or later, Mono 5.4 or higher, Xamarin.iOS 10.14 or higher, Xamarin.Mac 3.8 or higher, Xamarin.Android 8.0 or higher and Universal Windows Platform 10.0.16299 or higher
In .NET standard 2.0 you can get following new things
- Rich API support
- Support to Visual Basic
- NET Core CLI support
Here are some advantages of .NET standard.
Advantages of .NET Standard
- Version implementation, compatibility and code sharing is the headache for developers, .NET Standard helps to resolve the issues by bringing API support under one roof.
- .NET standard saves re-compile time and increase cross platform support
- .NET Standard support open source technique, its code is available on GitHub
- .NET Standard 2.0 includes a compatibility shim for .NET Framework binaries, significantly increasing the set of libraries that you can reference from your .NET Standard libraries.
- .NET Standard is the replacement for Portable Class Libraries (PCLs) which also used to building multi-platform .NET libraries with the help if tooling story (.NET standard 2.0)
Microsoft has developed a class library which contains set of API (base libraries) that support .NET framework, .NET Core and other cross-platform operating systems, this set of class libraries is known as .NET Standard. It is the alternative to PCL (portable class library). Developers can use this library to develop apps that support multiple platform apps. We can say it is the roadmap to run your apps in the different environment with a single set of code.
Take our free skill tests to evaluate your skill!
In less than 5 minutes, with our skill test, you can identify your knowledge gaps and strengths.