If you are working as a developer and want to switch to the .NET world, you will need to know what are possibilities for you inside. As .NET Framework is the most popular technology from .NET Ecosystem you can use it to build different kinds of applications, but these days, there are some new things, like .NET Core and .NET Standard library. Is this something we can use in a project or build?
There is some confusion when trying to use specific tech stack in the .NET ecosystem, as there are so many options, such as which type of runtime should you use? In this text we will try to make all of these points clear.
In general, .NET is an open source developer platform, created by Microsoft, for building many different types of applications, such as: web, mobile, desktop, games, etc. It consists of different tools, programming languages and libraries. Lets start with a brief history of the .NET.
The history behind .NET
During 1990s, Microsoft started to work on something called .NET Strategy. The key point of this strategy was to encompass all Microsoft products and add .NET to existing product names. In the 2000s, .NET framework was known as the Next Generation Windows Services (NGWS). First beta versions of .NET framework were released in the late 2000s and the first version .NET 1.0 was released on February 13, 2002. Since then many versions were released with new features. Some of the most important were:
|Year||C#||.NET||CLR||Included in vs||Language features||Roslyn compiler|
|2002||1.0||.NET Framework 1.0||1.0||2002||Classes, Structs, Interfaces, Events, Properties, Delegates, Operators, Expressions, Statements, Attributes||Legacy|
|2003||1.1||.NET Framework 1.1||1.1||2003||-|
|2003||1.2||.NET Framework 1.1||1.1||2003||-|
|2005||2.0||.NET Framework 2.0||2.0||2005||Generics, Partial types, Nullable value types, Anonymous methods, Iterators, Covariance and Contravariance, Static classes, Delegate inference, Method group conversions, Getter/setter separate accessibility||Legacy|
|2006||2.0||.NET Framework 3.0||2.0||2008||-|
|2007||3.0||.NET Framework 3.5||2.0||2008||Implicit typed local variables, Extension methods, Auto implemented properties, Anonymous types, Lambda expressions, Query expressions, Expression tree, Partial methods||Legacy|
|2010||4.0||.NET Framework 4.0||4.0||2010||Dynamic binding, Named and optional arguments, Generic Covariant and Contravariant, Type equivalence||Legacy|
|2012||5.0||.NET Framework 4.5||4.0||2012||Asynchronous methods, Caller information attributes||Legacy|
|2013||5.0||.NET Framework 4.5.1||4.0||2012||-|
|2014||5.0||.NET Framework 4.5.2||4.0||2012||-|
|2015||6.0||.NET Framework 4.6||4.0||2015||Static imports, Exception filters, Auto-property initializers, Expression body definition, Null propagating, String interpolation, nameof, Dictionary initializer||Open source|
|2015||6.0||.NET Framework 4.6.1||4.0||2015||-|
|2016||6.0||.NET Framework 4.6.2||4.0||2015||-|
|2016||6.0||.NET Core 1.0||CoreCLR||2015||-|
|2016||6.0||.Net Core 1.1||CoreCLR||2015||-|
|2017||7.0||.NET Framework 4.7||4.0||2017 (v15.0)||Out variables, Tuples and deconstruction, Pattern matching, Local functions, Expanded expression bodied members, Ref locals and returns, Discards, Binary literals, Digit separators, Throw expressions||Open source|
|2017||7.1||.NET Core 2.0||CoreCLR||2017 (15.3)||Async Main method, Default literal expressions, Inferred tuple element names, Pattern matching on generic type parameters||Open source|
|2017||7.2||.NET Framework 4.7.1||4.0||2017 (15.5)||Non-trailing named arguments, Underscore prefix in numeric literals, Private protected access modifier, Conditional ref, Efficient safe code syntax improvements||Open source|
|2018||7.3||.NET Framework 4.7.2||4.0||2017 (v15.7)||Small improvements to existing features||Open source|
|2018||7.3||.NET Core 2.1||CoreCLR||2017 (v15.7)||-|
|2018||7.3||.NET Core 2.2||CoreCLR||2017 (v15.7)||-|
|2019||7.3||.NET Framework 4.8||4.0||2017 (v15.7)||-|
|2019||8.0||.NET Core 3.0||CoreCLR||2019 (v16.3)||Readonly members, Default interface methods, New pattern matchings, Using declarations, Static local functions, Disposable ref structs, Nullable reference types, Asynchronous streams, Indices and ranges, Null-coalescing assignment, Unmanaged constructed types, Stackalloc in nested expressions, @$ order||Open source|
|2019||8.0||.NET Core 3.1||CoreCLR||2019 (v16.3)||-|
|2020||9.0||.NET 5.0||CoreCLR||2019 (v16.8)||Records, with expressions, Init only setters, Top-level statements, New pattern matchings, Performance and interop improvements, Fit and finish features, Support for code generators, Target-type new expressions, static anonymous functions, Target-type conditional expressions||Open source|
The image below shows timeline of .NET main events:
.NET Ecosystem: An overview
Currently, in 2020. .NET Ecosystem consists of different components in the development platform. It encompasses different runtimes, such as:
- .NET Framework (WPF, Windows Forms, ASP.NET) - Windows centric.
- .NET Core (ASP.NET Core, Universal Windows Platform - UWP) - Cross-platform, works side-by-side with other versions.
- .NET 5 (ASP.NET Core, WPF, Windows Forms, Blazor) - A unifying platform for desktop, Web, cloud, mobile, gaming, IoT, and AI applications.
- Mono for Xamarin (IOS, OS X, Android) - Cross-platform.
All of the above runtimes implement .NET Standard Library, which is a specification of .NET APIs that have implementations for each runtime. So that code that is created for one runtime, can be executed with other runtime.
All the runtimes uses tools and infrastructure to compile and run code. This includes languages (C#, Visual Basic), compilers (Roslyn), garbage collection, as well as build tools like MS Build, or (Core) CLR.
In this section we will look at main .NET runtimes. We consider .NET runtime as anything that implements ECMA-335 Standard for .NET.
.NET Framework and .NET Core can be downloaded from the official Microsoft site. LTS (Long-term support) versions have extended support period and should be used.
.NET Framework is a software development framework for building and running applications on Windows. It is party open-sourced at here. .NET Framework consists of Common Language Runtime (CLR), .NET Framework Class library and Application workloads (WPF, Windows Forms and ASP.NET). CLR is part of common infrastructure than run code, jit, do garbage collection (C#, VB.NET, F#), etc. Code that is managed by CLR is called managed code. Code is compiled into Common Intermediate Language (CIL) and stored in assemblies (with .exe or .dll extension). When application runs, CLR takes assembly and uses just-in-time compiler (JIT) to transpile machine code into code that can run on specific computer architecture.
.NET framework library contains classes, interfaces and values types that provides capatibilites, such as string, file system support, etc. It allows creating different type of applications, such as: console applications or Windows Forms, Windows Communication Foundation (WCF), Windows Workflow Foundation (WF), Windows Presentation Foundation (WPF), ASP.NET (Forms, Web API), Azure (WebJobs, Cloud Services). Most of those are specific to Windows platforms and use Windows API, so they work only on Windows platform.
If you want to run applications that are built by using .NET Framework you need to install it first, although Windows already comes with some versions installed. Each version have CLR and library. It is possible to install multiple versions, side by side (only major versions). Minor versions will override existing versions, as they don’t contain braking changes. For example for .NET 4.2.3: major version is 4 (new CLR), 2 minor version means (new library, which introduces new features) and 3 revision (bug fixes).
.NET Framework is installed usually at C:\Windows\Microsoft.NET\Framework (or Framework64). Inside, you will find folders with all major versions installed.
.NET Core is one of runtimes in .NET Ecosystem. It is released in 2016. and its open-sourced (https://github.com/dotnet/core). It does not represent a new version of .NET Framework and will not replace it. Its completely independent version, which is build to allow cross-platform capatibility to application development. .NET Core consists of App Host (dotnet.exe) that run CLR and Library. It has Common language runtime (CoreCLR) and .NET Core Class Library.
CoreCLR uses JIT Compilation and garbage collection to run code. It supports C#, VB.NET and F#. .NET Core has .NET Core Class Library, which includes classes that provides different capatibilities and its a smaller subset of .NET Framework library. It supports different types of application workloads, such as ASP.NET Core (MVC and API), console applications and UWP (currently). UWP provides a common type system, APIs, and application model for all devices running on Windows 10. From the .NET Core 3.0 SDK it includes support for Windows Forms applications, including Windows Forms Designer.
.NET Core can run on different platforms: Windows Client, Server, IoT, Linux, Ubnutu, FreeBSD, Tizen, Mac OSX and can be installed side-by-side of different versions, per machine or user.
.NET Core is installed in C:\Program Files\dotnet\shared\ Microsoft.NETCore.App[versions], which live side by side.
In addition, its possible to create self-contained version, which don’t need installed .NET core on the host machine, as it packs app host in the resulting .exe file. The disadvantage is that the the deployment will be larger. It is run via:
dotnet publish -r linux-x64 --self-contained
.NET 5 is the latest runtime in .NET Ecosystem. It is released in November 2020. with a goal to unifying development for desktop, Web, cloud, mobile, gaming, IoT, and AI applications. The earlier setup goal was to produce a single .NET runtime and framework, cross-platform, integrating the best features of .NET Core, .NET Framework, Xamarin, and Mono. However, due to the global health pandemic, the unification was postponed to .NET 6 (expected to be released in November 2021). .NET 5 consists of App Host (dotnet.exe) that run CLR and Library. It has Common language runtime (CoreCLR) and .NET 5 Class Library.
.NET 5.0 has a nearly identical platform support as .NET Core 3.1, for Windows, macOS, and Linux.
.NET 5 is installed in C:\Program Files\dotnet\shared\ Microsoft.NETCore.App[versions], which live side by side.
.NET 5 is a shared code base for .NET Core, Mono, Xamarin, and future .NET implementations. Also, target framework names (TFMs), which are used to express which version of .NET targeting, are updated, so we have now net5.0. This is for code that runs everywhere. It combines and replaces the netcoreapp and netstandard names and net5.0-windows that represent OS specific flavors of .NET 5 that include net5.0 plus OS-specific bindings.
.NET 5 improve significantly single-file applications. Single-file applications are published and deployed as a single file, which includes the app and all of its dependencies. They can also be self-contained, which means they carry their own .NET runtime. Even thoguh single fileapplications were already a think in .Net Core, their behavior is completely different. In .Net Core 3.1, in fact, it packages binaries into a single file for deployment and then unpacks those files to a temporary directory to load and execute them. With .Net 5 instead when the app is run dependencies are loaded directly from that file into memory. .NET 5 also brings smaller single-file applications with more efficient memory usage and can be used in microservices containerized applications.
In addition, one of the important new features is support for ARM64, that will allow .NET 5 applications to run natively on Windows and ARM hardware (such as new Apple M1 ARM-based processors). This means that is has the widest OS support of any .Net version before.
In fact it runs on:
- Windows 7 SP1, 8.1 and 10, on both x86 and x64 architectures and for the first time on Arm64.
- Windows Server and Windows Server Core 2012 R2 and higher, on both x86 and x64, and Nano Server 1809 and higher on x64.
- Linux: all the major distributions including Alpine, CentOS, Debian, RedHat, Suse, Ubuntu and more, on the x64 architecture but in some cases supporting also Arm32 and Arm64.
- MacOS, from the version 10.13 onwards, on the x64 architecture
Mono For Xamarin
Mono is a clone of .NET framework runtime. Mono is created in 2001., but part for Xamarin is released in 2011. and its open source: https://github.com/mono/mono and www.mono-project.com. Microsoft acquired Xamarin in 2016., making it a fully open-source branch of the .NET platform. It consists of Mono runtime and Xamarin Class Library and can run application workloads like IOS, OS X and Android.
Mono is similar to .NET Core and includes Garbage collection, JIT, AOT and full support for C# (not VB.NET and F#). The Mono AOT compiler enables .NET code to be built into a single native code executable that can run on a machine, much like C++ code. Mono for Xamarin has a class library that support creating applications (for IO, collections, etc). But its a subset of .NET framework, there are not all components supported.
It can run following workloads: Apple IOS applications, MAC OS X applications (desktop), Android applications, etc. and allows you to share code between these platforms and they run as native applications on devices that run on Mono. Each application is bundled with the Mono runtime and a class library. There is no need to install Mono on a device.
Over time it branched out into wider areas, such as game development, where Unity and Mono for Xamarin have long worked together to provide C# support in Unity.
Other frameworks: .NET Compact Framework & .NET Micro Framework
These are specific frameworks with a specific purpose. Both runtime were attempts to provide cut-down runtimes that would run on more constrained devices, such as PDAs, mobile phones factory controllers, etc. For example, .NET Micro Framework was build for resource-constrained devices with at least 256KB of flash and 64KB of RAM memory.
Silverlight was a popular cross-platform, .NET technology that enabled building rich media experiences for browsers. It was released on 2007 and had multiple capatibilites such as playing videos, download medias, creating rich UI and animations, etc. In 2015. Microsoft decided to stop supporting Silverlight in October 2021.
Besides Microsoft official runtimes, there are .NET runtimes made by community, such as DotGNU Portable.NET, DotNetAnywhere, CosmosOS and CrossNet. All of them have a slighty different approach to build such a framework.
As different runtimes uses different class libraries, e.g., .NET Framework uses .NET Framework class library, while .NET Core contains its own class library, as well as Xamarin with its own class library. In this way its hard to share code between different runtimes, as they don’t use the same APIs. Microsoft solution to this is .NET Standard library, released in 2016. It represent set of (formal) specifications that say which APIs you can use and its implemented by all runtimes. It is evolution of Portable Class Libraries (PCL). Specific runtimes implement specific version of .NET Standard (implementing specific set of APIs). E.g., .NET Framework 4.6.1 implements .NET Standard 2.0 and .NET 5 implements .NET Standard 2.1 (link).
The differences between .NET Standard and Portable Class Libraries (which is library that can be used on different platforms).
- .NET Standard represent set of API defined by Microsoft, while PCL is using API dependent on platform which is chosen.
- .NET Standard is platform agnostic, while PCL can target limited set of platforms.
Each version of .NET Standard has set of APIs (e.g. System.Drawing) and it include all APIs of previous version, so its backward compatible. Specific .NET runtime versions implement specific .NET Standard versions. Lower versions of .NET Standard cover more platforms, which means that you should always target the lowest version possible.
In .NET 5 .NET Core and .NET Standard are merged, which means that we now have a shared code base for all .NET workloads, whether it’s desktop apps, cloud services, or mobile apps. However, .NET 5 does not replace .NET Standard. .NET 5 may run on phones and Windows desktop apps. New TFM net5.0 will represent the API set that available on all platforms. In addition, OS-specific TFMs are added (such as net5.0-windows) that targets all of the .net5.0 + APIs specific to Windows.
In general, we can use:
- netstandard2.0 to share code between .NET Framework and all other platforms.
- netstandard2.1 to share code between Mono, Xamarin, and .NET Core 3.x.
- net5.0 for code sharing moving forward.
.NET Framework tooling
The purpose of the tooling is to make applications. For the .NET Framework tooling, use MSBuild, who is invoked when code is build in Visual Studio or it can be called from a command line. MSBuild knows how to build or who should compile them. If the code is C#/VB.NET he will call .NET Compiler Platform (Roslyn). The result of compilation is binary file (.EXE or .DLL) with intermediate language (IL). It can be interpreted by CLR. CLR contains JIT-compiler, which compiles to native code, which OS understands. CLR has tools like Garbage Collector to clean memory when not needed.
.NET Core and .NET 5 tooling
MSBuild is also used in .NET Core tooling, as well as .NET Compiler Platform (Roslyn). It procudes binaries (.EXE, .DLL) with intermediate language (IL), which is used by the Core Common Language Runtime (CoreCLR). CoreCLR is different from .NET Framwork CLR, as it can run on multiple frameworks. It has JIT-Compiler that can compile IL into native code for Windows, MacOS and Linux.
There is another path to compile apps, when UWP is compiled, its compiled with AOT-Compiled (.NET Native), which produced Native code from IL and produced code as deployable package instead of compiling at runtime, which has performance benefit.
CoreCLR and Native Code is loaded by app host process (dotnet.exe).
.NET Core includes new Command Line Interface, called dotnet cli. It allows you to create new projects
dotnet new, build applications
dotnet build, run applications
dotnet run or deploy them
dotnet publish. You can try with
dotnet --info and check which SDKs and runtimes you have installed and on which disk location are they installed.
Mono for Xamarin tooling
MSBuild is used again to run build process but only for files in C#. If there are C# code for Android, its compiled via Xamarin Compiler and compiled for Android platform (IL). Then Mono Runtime, which as JIT-Compiler, takes IL and produces Native code specific for that Android device on demand at runtime. It has also runtime services such as Garbage Collector.
If we have C# code for IOS, its compiled via Xamarin Compiler, who pre-compile and produce package native for IOS (uses ARM Assembly language).
Visual Studio IDE
Visual Studio is a Microsoft IDE used for building, debugging, and publishing applications across all platforms, including Android and iOS. Visual Studio is integrated with .NET and provides the features of language-specific environment.
Visual Studio can be run on Windows and Mac. There is a free community version to be used. Visual Studio for Mac is totally different environment than one for Windows, as it is based on MonoDevelop, IDE for Linux, macOS and Windows, built by Xamarin company (earlier called Xamarin Studio).
Additionaly, it is possible to use Visual Studio Code to develop applications on .NET Core platform.
Outside Microsoft world JetBrains Rider is making an impact. By using it, one can develop .NET, ASP.NET, .NET Core, Xamarin or Unity applications on Windows, Mac, Linux.
There are different kinds of libraries that can be used in the .NET ecosystem, most of which can be found as NuGet packages. NuGet is a package manager build for .NET that contains more than 90,000 packages.
Different kinds of .NET applications can be written in C#, F# or Visual Basic.
C# is a simple, modern, object-oriented programming language, whose roots are in the C family of languages. The current version is 9.0 and is supported on .NET 5 and .NET Standard 2.1. More on C# in general here and on C# 9.0 features here.
F# is a cross-platform, open-source, functional programming language for .NET. More about F# here.
Visual Basic is traditional programming language from Microsoft kitchen with simple syntax for building type-safe, object-oriented applications. More on Visual Basic here.
The question is when to use each of the runtimes. This is a suggestion:
- .NET Framework should be used to:
- build Forms applications.
- that cannot run cross-platform (Windows).
- .NET Core should be used if:
- build high performance applications with small footprint.
- that run cross-platform.
- .NET 5 should be used if:
- for all new development.
- that run cross-platform.
- Mono for Xamarin should be used:
- build mobile applications that utilize native features and cross-platform.
If you use .NET Core or .NET 5 you can use framework-dependent applications or self-contained applications. Use Framework-dependent if no target os is needed, you need small deployment (installed on machine). But for self-contained app there is control over version and .NET Core and .NET 5 doesn’t need to be installed, but the deployment is larger and need to select target OS.
If we choose between ASP.NET or ASP.NET Core, ASP.NET is much older technology that runs only on Windows, but it has large set of capabilities and features. ASP.NET Core can be run cross-platform and its designed for high-performance and can run self-contained. It has less capabilities and 3rd party libraries than ASP.NET. No ASP.NET Forms.
Regarding the usage of sharing code, we need to check first do we need it. If yes, we should use .NET Standard library. If no, than we share code between applications in the same runtime, then we can use library with that specific runtime. This enabled runtime specific features not available in .NET Standard.
Look to the future
As .NET 5 didn’t bring all planned features, due to some technical problems but as well as delays caused by COVID-19 pandemic, some of the original plans for .NET 5 shifted to .NET 6 coming in November 2021., which will be a Long-Term Support (LTS) release. We can see .NET 5 as a first step in the .NET journey. The most significant goals for .NET 6 are already set. Many of them target improvements that didn’t make it into .NET 5, like a next-generation Xamarin that lowers the barriers between desktop and native mobile development, and better integration between the many different Windows UI toolkits. .NET 5 is a key technology for the separation of the Windows APIs from the OS, the Project Reunion merger of WinRT and Win32 APIs, and the move to both WinUI 3 and MAUI as UI layers. The Windows team continues to work on Project Reunion as the next step forward for UWP and related technologies.
In 2020. Microsoft announced that there will be a new first-class UI framework for creating cross-platform applications, called .NET MAUI. It will be an evolution of Xamarin.Forms and will simplify developer workflow and a project structure into a single project to target multiple platforms. General availability of the .NE MAUI will be with .NET 6 in November of 2021.
In the new website that Microsoft created, we can see a vision for .NET. It called Themes of .NET. First made public late last year, themesof.net collects GitHub issues and aggregates them into themes and epics (terminology that stems from Agile project management). In this site we can see that Microsoft will prioritize following topics:
- Making .NET accessible for beginners and education. Idea is to lower the entry barriers to .NET — in the form of building an open-source computer-science curriculum that could run entirely online in .NET notebooks.
- Blazor on the desktop. This would be an interesting direction and probably a competitor for Electron. Giving Blazor a broader reach is an official goal and looks like a good step.
- Improve the .NET ecosystem. The idea is that as many developers avoid third-party tools when they build their .NET development stack, so if .NET is going to continue to grow, it needs to help other developers succeed — particularly those with open-source projects that the entire community can use.
- Better development performance. This includes long-awaited enhancements like hot-reloading across ASP.NET and ahead-of-time compilation for Blazor. It’s an area where Microsoft says competing platforms are still edging out .NET.
- Democratize ML.NET. The gap between toy examples in ML.NET framework (introduced in 2018.) and practical integration is huge, and many a developer is carried off that cliff in a moment of enthusiasm. Microsoft developers have proposed a host of small improvements that may help non-experts integrate machine learning features into their applications.
So, looking at the latest trends, including Azure as one of the main Cloud platforms, future for the Microsoft-developer world is looking great. With open source and cross-platform as key priorities seems like a right direction in the years to follow.
.NET Guide – the general documentation by Microsoft for newbies.
.NET on Q&A – answers to technical questions about .NET.
.NET Framework – the original .NET documentation.
Xamarin – documentation for mobile development.
.NET Foundation – .NET open-source community.
C# Guide - official C# documentation.
NuGet – the place to find all .NET packages.
.NET Core and Framework – download it here.
Themes of .NET - vision for the .NET.
.NET Developer Community – developer community and support with links to social media, forums, blogs, live workshops, and organizations like .NET foundation.
Thanks for reading !