A Brief Walk-Through of the .NET Ecosystem
This article provides insight into the many different tech stacks in the .NET ecosystem and how to navigate choosing the option for you.
Join the DZone community and get the full member experience.
Join For FreeIf you are working as a developer and want to switch to the .NET world, you will need to know the possibilities of the ecosystem. As the.NET framework is the most popular technology from the .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. Is this something we can use in a project or build?
There is some confusion when trying to use specific tech stacks in the .NET ecosystem, as there are so many options, such as which type of runtime to use. In this article, 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, and desktop. It consists of different tools, programming languages, and libraries. Let's start with a brief history of .NET.
The History Behind .NET
During the 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, the .NET framework was known as the Next Generation Windows Services (NGWS). The first beta versions of the .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 have been released with new features. Some of the most important are:
- .NET Framework 2.0 (November 2005): generic collections, iterators, nullable types, etc.
- .NET Framework 3.0 (November 2006): Introduced WPF, WCF, and WWF.
- .NET Framework 3.5 (November 2007): Introduced AJAX, LINQ, and ASP.NET MVC.
- .NET Framework 4.0 (April 2010): MEF, DLR, task parallel library, Razor view engine, new C#/VB language features.
- .NET Framework 4.5 (August 2012): support for Async, zip compression support.
- .NET Core 1.0 (November 2014): first version which included cross-platform support; introduced ASP.NET 5 and .NET Native.
- .NET Core 2.0 (August 2017): the second version, with major performance improvements and implemented .NET Standard 2.0.
- .NET Framework 4.8 (April 2019): final version included JIT enhancements, High DPI enhancements for WPF applications, accessibility improvements, performance updates, and security enhancements.
- .NET Core 3.0 (September 2019): performance improvements, C# 8.0 new features, implemented .NET Standard 2.1, included Windows Desktop support .NET Core for Windows Forms and WPF.
- .NET 5 (November 2020): single .NET runtime and framework that can be used everywhere and that has uniform runtime behaviors and developer experiences.
The image below shows the timeline of the major .NET events:
The .NET Ecosystem: An Overview
Currently, in 2021, the .NET ecosystem consists of many different components. 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, which is a specification of .NET APIs that have implementations for each runtime. This was done so that code created for one runtime could be executed with other runtimes.
All the runtimes use 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.
.NET Runtimes
In this section, we will look at the main .NET runtimes. We consider .NET runtimes to be anything that implements the ECMA-335 Standard for .NET.
.NET Framework and .NET Core can be downloaded from the official Microsoft site. LTS (long-term support) versions have an extended support period and should be used.
.NET Framework
.NET Framework is a software development framework for building and running applications on Windows. It is partly open-sourced here. .NET Framework consists of Common Language Runtime (CLR), the .NET Framework Class library, and application workloads (WPF, Windows Forms and ASP.NET). CLR is part of a common infrastructure than runs code, has a Just-in-Time (JIT) compiler, performs garbage collection, and more. Code that is managed by CLR is called managed code. Code is compiled into the Common Intermediate Language (CIL) and stored in assemblies (with .exe or .dll extensions). When an application runs, CLR takes the assembly and uses the JIT compiler to transpile machine code into code that can run on specific computer architectures.
.NET Framework contains classes, interfaces, and value types that provide specific capabilities, such as strings, file system support, etc. This allows for the creation of different types 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 APIs), and Azure (WebJobs, Cloud Services). Most of those are specific to Windows platforms and use Windows APIs, so they work only on a Windows platform.
If you want to run applications that are built using .NET Framework you need to install it first, although Windows already comes with some versions installed. Each version has a CLR and a library. It is possible to install multiple versions, side-by-side (only with major versions, though). Minor versions will override existing versions, as they don’t contain braking changes. For example, for .NET 4.2.3 the major version is 4 (new CLR), while the 2 is the minor version (new library, which introduces new features), and 3 symbolizes the latest revisions (bug fixes).
.NET Framework is usually installed at C:\Windows\Microsoft.NET\Framework (or Framework64). Inside, you will find folders with all the major versions installed.
.NET Core
.NET Core was released in 2016 and is open-sourced (https://github.com/dotnet/core). It does not represent a new version of .NET Framework and will not replace it. It's a completely independent version, which was built to give cross-platform capabilities to application development. .NET Core consists of App Host (dotnet.exe) that runs the CLR and Library. It has a 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 uses the .NET Core Class Library, which includes classes that provide different capabilities, and its a smaller subset of .NET Framework. 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. Since the .NET Core 3.0 SDK, it has included support for Windows Forms applications, including Windows Forms Designer.
.NET Core can run on different platforms, including: Windows Client, Server, IoT, Linux, Ubnutu, FreeBSD, Tizen, and Mac OSX and can be installed side-by-side with 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, it's possible to create self-contained versions, which don’t need an installed version of .NET Core on the host machine, as it packs an app host in the resulting .exe file. The disadvantage is that the deployment will be larger. It is run via the following command:
dotnet publish -r linux-x64 --self-contained
.NET 5
.NET 5 is the latest runtime in the .NET Ecosystem. It was released in November 2020, with the goal of unifying development for desktop, web, cloud, mobile, gaming, IoT, and AI. The earlier setup's goal was to produce a single, cross-platform .NET runtime and framework that integrated 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 runs CLR and Library. It has the Common language runtime (CoreCLR) and .NET 5 Class Library.
.NET 5.0 has nearly identical platform support to .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 is being targeted, are updated, so we now have 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 significantly improved 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 though single file applications were already a thing in .NET Core, their behavior is completely different. In .NET Core 3.1, in fact, it packages' binaries are held in a single file for deployment and then it unpacks those files to a temporary directory to load and execute them. With .NET 5, instead, when the app is run its 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-based and 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, Red Hat, Suse, Ubuntu, and more, on the x64 architecture, but, in some cases, it also supports ARM32 and ARM64.
- MacOS, from the version 10.13 onwards, on the x64 architecture.
Mono for Xamarin
Mono is a clone of the .NET framework runtime. Mono was created in 2001, but the part that works with Xamarin was released in 2011. Additionally, it's open sourced: 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 the 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 supports creating applications (for IO, collections, etc). But it's a subset of .the NET framework and not all components are supported.
It can run the following workloads: Apple iOS applications, MAC OS X applications (desktop), Android applications, and allows you to share code between these platforms. Additionally, Mono apps 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 and .NET Micro Framework
These are specific frameworks with a specific purpose. Both runtimes were attempts to cut-down on the length of runtimes that would run on more constrained devices, such as PDAs, mobile phone factory controllers, etc. For example, .NET Micro Framework was built for resource-constrained devices with at least 256KB of flash and 64KB of RAM memory.
Silverlight
Silverlight was a popular cross-platform, .NET technology that enabled building rich media experiences for browsers. It was released in 2007 and had multiple capabilities such as playing videos, downloading media, creating rich UIs and animations, etc. In 2015, Microsoft decided to stop supporting Silverlight in October 2021.
Community Projects
Besides Microsoft's official runtimes, there are .NET runtimes made by the community, such as DotGNU Portable.NET, DotNetAnywhere, CosmosOS, and CrossNet. All of them have a slightly different approach to building out applications.
.NET Standard
Different runtimes use different class libraries. For example, .NET Framework uses the .NET Framework class library, while .NET Core contains its own class library, as well as Xamarin with its own class library. In this way, it's hard to share code between different runtimes, as they don’t use the same APIs. Microsoft's solution to this is the .NET Standard library, released in 2016. It represent a set of (formal) specifications that say which APIs you can use and its implemented by all runtimes. It is an evolution of Portable Class Libraries (PCL). Specific runtimes implement specific version of .NET Standard (implementing a specific set of APIs). For example, .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 are libraries that can be used on different platforms) include:
- .NET Standard represents a set of APIs defined by Microsoft, while PCL uses APIs dependent on the chosen platform.
- .NET Standard is platform agnostic, while PCL can target a limited set of platforms.
Each version of .NET Standard has a set of APIs (e.g. System.Drawing) and it includes all APIs from previous versions, so it's 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, Microsoft merged .NET Core and .NET Standard, 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. The new TFM net5.0 will represent the API set that's available on all platforms. In addition, OS-specific TFMs are added (such as net5.0-windows) that target 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.
Tools
.NET Framework Tooling
The purpose of the tooling is to make applications. For .NET Framework tooling, use MSBuild, which is invoked when code is built in Visual Studio or it can be called from the command line. MSBuild knows how to build or what should compile. If the code is C#/VB.NET it will call the .NET Compiler Platform (Roslyn). The result of this compilation is a binary file (.exe or .dll) with intermediate language (IL). It can be interpreted by CLR. CLR contains a JIT compiler, which compiles the data to native code that your OS understands. CLR has tools like garbage collectors to clean memory when it's not needed.
.NET Core and .NET 5 Tooling
MSBuild is also used in .NET Core tooling, as well as the .NET Compiler Platform (Roslyn). It produces binaries (.exe, .dll) with intermediate language (IL), which is used by the Core Common Language Runtime (CoreCLR). CoreCLR is different from .NET Framework CLR, as it can run on multiple frameworks. It has a 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 produces native code from IL as well as code as deployable packages instead of compiling them at runtime, which has performance benefits.
CoreCLR and Native Code is loaded by app host processes (dotnet.exe).
.NET Core includes a 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 this 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 processes, but only for files in C#. If there is C# code for Android, its compiled via Xamarin Compiler and compiled for Android platform (IL). Then Mono Runtime, which has a 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 collection.
If we have C# code for iOS, it's compiled via Xamarin Compiler, which pre-compiles and produces packages native for iOS (uses the ARM Assembly language).
As a side note on Xamarin, it also has different competitors, such as Uno Platform and Avalonia UI. There is also a new kid on the block from Microsoft, called Blazor. All of these tools mainly use WebAssembly (WASM) in combination with C# and XAML or JavaScript to allow developers to deploy apps in the browser, but also on different devices.
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 environments.
Visual Studio can be run on Windows and Mac. There is a free community version to be used. Visual Studio for Mac is a totally different environment than the one for Windows, as it is based on the MonoDevelop IDE for Linux, macOS, and Windows, built by Xamarin (previously known as Xamarin Studio).
Additionally, it is possible to use Visual Studio Code to develop applications on the .NET Core platform.
Outside the 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, and Linux.
Libraries
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 built for .NET that contains more than 90,000 packages.
Languages
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. You can find out 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. You can find out more about F# here.
Visual Basic is a traditional programming language from Microsoft with a simple syntax for building type-safe, object-oriented applications. You can find out more on Visual Basic here.
Usage
The question is when to use each of these runtimes. Here's my suggestion:
- .NET Framework should be used to build Forms applications that cannot run cross-platform (Windows).
- .NET Core should be used to build high performance applications with a small footprint that run cross-platform.
- .NET 5 should be used for all new development that runs cross-platform.
- Mono for Xamarin should be used to build mobile applications that utilize native and cross-platform features.
If you use .NET Core or .NET 5 you can use framework-dependent applications or self-contained applications. Use framework-dependent apps if there's no target OS needed, as you'll just need a small deployment (installed on the machine). For self-contained apps, there is a control over version and .NET Core and .NET 5 don’t need to be installed, but the deployment is larger and needs to select a 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 a 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 third-party libraries than ASP.NET. Additionally, ASP.NET does not include a Forms functionality.
Regarding the sharing of code, we first need to check if it's necessary. If it is, we should use .NET Standard. If it's not, then we share code between applications in the same runtime, then we can use the .NET library with that specific runtime. This enables 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 as well as delays caused by the 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 the next 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 .NET MAUI will be with .NET 6 in November 2021.
On the new website that Microsoft created, we can see a vision for .NET. It's 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). On this site, we can see that Microsoft will prioritize the following topics:
- Making .NET accessible for beginners and education. The 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, 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, the future of the Microsoft-developer world is looking great. With open source and cross-platform as key priorities, it seems to be headed in the right direction in the years to follow.
Useful Links
.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 world.
.NET Developer Community – developer community and support with links to social media, forums, blogs, live workshops, and organizations like the .NET Foundation.
Published at DZone with permission of Milan Milanovic. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments