Which Version of .NET Should You Use? Explanation of the .NET Environment

In this post, we’ll look at the different versions of .NET. Especially when you’re starting out in this environment, you end up with a lot of questions, partly due to marketing and partly trial and error, because Microsoft hasn't always been the best at naming things in the past.

Although, as we’ll see, this problem won’t be as big in the future.

 

 

1 - The .NET Environment

On this channel we mainly write code in C#, and for that reason, in other posts I have code examples explained. But at the end of the day we are writing text in a document, so we need software that can understand that document and run it on the machine.

In the case of C#, the software that transforms your code into something the machine can understand is a framework called .NET.

 

C# is a part of .NET, but to be fair, in the real world, 99% of the time, you’ll refer to C#, but as I said, it’s not the only one.

The .NET Framework can convert not only C# but also F# and Visual Basic into code the machine can execute.

 

 

2 - What is .NET Framework?

It was in 2002 when Microsoft released .NET Framework, almost 20 years ago, and honestly, it's still widely used today.

 

.NET Framework is the engine that understands your code in C#, F#, or Visual Basic and runs it on the machine using the Runtime. It also handles code compilation and the garbage collector.

 

On top of providing the CLR (common language runtime), when we program in .NET Framework, we do so using the code library Microsoft gives us, which includes a huge array of features, classes, interfaces, types, and many other properties.

 

With it, you can make web applications with ASP.NET, desktop apps with Windows Presentation Foundation, or if they’re older, WinForms and console applications.

net framework

 

  • Note: .NET Framework also gives us access to Windows APIs or other Microsoft software like Excel or Word. We have all worked at that typical company that has Office installed on the server for making invoices and such with the software.

 

On the downside, applications built with .NET Framework only run on Windows; and if you’re building web apps, they need to be hosted on IIS (Internet Information Server).

Finally, applications built with .NET Framework are very heavy (in megabytes).

 

 

2.1 - When to Use .NET Framework?

If you are reading this post, it means you’re at least in 2021, so I’ll be clear: NEVER.

We’ll look at other options later.

 

 

3 - What is .NET Core?

Similar to the previous case but more modern, this engine launched its first version in 2016 and is completely open source. This has been crucial as the community embraced it with open arms, which has helped its proper development over the years.

The way applications run in .NET Core is a bit different from how they ran in .NET Framework. With .NET Core, everything is executed in your appHost, which has access to the .NET Core library and the Core CLR.

 

It’s important to emphasize that it runs the core versions of the library and the CLR because they aren't the same as in .NET Framework, they’ve been refactored and often split into multiple libraries to be more lightweight.

This allows your application to be super lightweight since you only have the libraries or packages you really need to make it run. Of course, you can add whatever you want from the community via nuget or your own packages.

 

Thanks to this division, nowadays .NET comes with packages to create default web projects, whether MVC, API, or Blazor, either on server or WebAssembly.

And Universal Windows Platform apps for desktop applications.

what is .net core

As an important point of the move to .NET Core, note that code can be run on multiple platforms and architectures (x86, x64, ARM CPUs). If you create a web application, you’ll be able to develop and run it on Windows, Linux, or Mac.

This is a big advantage for companies in economic terms and also a big plus for users like me who have a small blog, since a Linux server costs half as much as a Windows server.

 

Another benefit is that you can install as many runtimes as you want on your machine to make all applications compatible. Even though you could do this before, it wasn't entirely necessary, as .NET Core is always backwards compatible. So, if you have the latest version of .NET Core installed, all your .NET Core apps should run just fine.

 

Finally, when you build applications with .NET Core, you can specify that they are a "self contained application", which means not only your app gets packaged, but also all required components and the runtime so it can run on any machine.

 

 

3.1 - When to Use .NET Core?

Today, at the end of 2021, you should use .NET Core version 3.1 for those web, console, or desktop projects you want in production and want to be stable.

 

Keep in mind .NET Core 3.1 is an LTS (Long Term Support) version, meaning it will be supported for quite some time. Specifically, .NET Core 3 was launched in December 2019 and its support ends in December 2022, providing three years of support from Microsoft (security patches, updates, etc.).

 

 

4 - What is .NET?

The title here may sound a bit redundant, making you think we’re referring to the .NET environment. And to an extent, yes, but no, we’re talking about the framework.

 

As you might have guessed, there was confusion in the .NET community about the name: .NET Framework, .NET Core, etc.

But, what did Microsoft think about it?

Microsoft decided the best thing to do was to combine both frameworks and give them a new name, so, in this case, they chose .NET (plain and simple), which actually seems to have made things even more confusing. Still, in a few years, nobody will remember this moment.

 

So yes, Microsoft combined .NET Core and .NET Framework and called it .NET, specifically, starting with version .NET 5.

 

And in theory, it’s completely retrocompatible with both frameworks, though I haven’t personally tried jumping from .NET Framework 4.8 to .NET 5. From .NET Core 3.1, it works smoothly, in fact, this website was initially built in .NET Core 3.1 and I later upgraded it to 5.

.NET explanation

 

4.1 - When to Use .NET?

In a few months, we’ll get the 2022 .NET Conf, where .NET 6 will be officially announced. You can already get it in preview mode, but for now the version we should choose is .NET 5.

 

Still, we'll need to migrate to .NET 6 in May 2022, since that’s when support for .NET 5 ends, and .NET 6 will be LTS.

 

Not much more to say, there’s no reason you shouldn't start your projects in .NET 5 or 6 (if you don’t mind deploying before the new features are truly stable).

 

 

5 - What is Xamarin?

Finally, within .NET we have another runtime, called "mono". Originally, mono was a fork of the .NET runtime, created to run .NET apps on multiple platforms.

In fact, many years ago (I’m already old!), you could code in C# on Mac with XCode using mono.

what is xamarin?

 

Today, it’s used to create mobile applications (Android, OSX) or Mac apps.

 

5.1 - When to Use Xamarin?

Currently, if you want to create mobile applications, I’d recommend Xamarin.

With .NET 6, both Blazor bindings and .NET MAUI (multi platform app) were supposed to be released, but apparently they’ve been delayed.

In this post, Scott Hunter explains why, and it’s basically because it doesn’t yet meet quality standards. They’d rather launch it later, roughly in mid-2022.

 

 

6 - What is .NET Standard?

Finally, let's talk about .NET Standard, which I’m sure you’ve heard of.

To sum it up, .NET Standard is meant for code that’ll be shared across different runtimes, since all the runtimes (.NET Framework, .NET Core, Xamarin) are able to run code written in .NET Standard.

 

But .NET Standard alone cannot be executed, you can't make a console application targeting .NET Standard. Instead, you’d use .NET Core or something else, and maybe use shared .NET Standard code.

 

You can think of .NET Standard as a layer before the runtime, basically something to add to the libraries that the language provides.

net standard explanation

 

6.1 - When to Use .NET Standard

If your code is .NET 5 or higher, you don’t need net standard (even though it can be executed), because the idea with .NET 5 is to also replace .NET Standard.

In this post by Immo Landwerth you can find more info on the subject.

 

On the other hand, if you’re in a typical company migrating from .NET Framework, you’re probably going from .NET Framework 4.8 to .NET Core 3.1 (most common case). In that scenario, it can help to have code shared between both projects.

 

For example, my Railway oriented programming library is written in .NET Standard

 

 

Which .NET version to choose?

If you’re here, you probably have doubts about which version to pick for your software.

 

As of today (September 2021), .NET 6 is here. But .NET 6 is in preview until May 2022, so if you don’t want to take a risk with new features that might not work quite right, you can always use .NET 5.

  • Note: when C# 10 is officially announced, I’ll do a post with the changes about it.

 

If you have to build a library that will be used by .NET Core, .NET, or even .NET Framework, you can use .NET Standard, and depending on the versions you want to support, you’ll need to choose a particular version.

For example, .NET Standard 2.0 is compatible with .NET 5, .NET Core 2.0 or higher, or even with .NET Framework 4.6.1.

 

Finally, if you’re looking for mobile or desktop applications, you’ll either have to choose Xamarin or wait until .NET 7 comes out, since unfortunately (although it was originally on the .NET 6 roadmap), it looks like it’s been delayed.

 

This post was translated from Spanish. You can see the original one here.
If there is any problem you can add a comment bellow or contact me in the website's contact form

Uso del bloqueador de anuncios adblock

Hola!

Primero de todo bienvenido a la web de NetMentor donde podrás aprender programación en C# y .NET desde un nivel de principiante hasta más avanzado.


Yo entiendo que utilices un bloqueador de anuncios como AdBlock, Ublock o el propio navegador Brave. Pero te tengo que pedir por favor que desactives el bloqueador para esta web.


Intento personalmente no poner mucha publicidad, la justa para pagar el servidor y por supuesto que no sea intrusiva; Si pese a ello piensas que es intrusiva siempre me puedes escribir por privado o por Twitter a @NetMentorTW.


Si ya lo has desactivado, por favor recarga la página.


Un saludo y muchas gracias por tu colaboración

© copyright 2025 NetMentor | Todos los derechos reservados | RSS Feed

Buy me a coffee Invitame a un café