It’s been twenty years given that the.NET structure initially showed up. Since April 2019, it has been iced up at.NET Structure 4.8, and.NET (formerly.NET Core) has changed it.
Starting with.NET Framework 4.5.2, Microsoft announced that.NET Structure would be connected to the lifecycle of the OS. For Windows 10, that suggests its lifecycle will certainly end in October 2025. Nevertheless, Windows 11 includes.NET Structure 4.8, so there’s no thrill to jump to.NET 6.
If you’re creating software in C#, you have a choice: Should you remain with.NET Structure or relocate to.NET?
Two Circumstances to Consider
Circumstance One: Web Work: All the development as well as enhancements are currently in.NET. This is where you’ll locate Blazor, SignalR, Microservices and also ASP.NET Core. However, the differences are relatively small, as.NET Core (the precursor to.NET) has been around for a long time, and also the upgrade assistant device will do the conversion. With all that in mind, allow’s move on to:
Situation 2: Desktop Work: Both WinForms and also WPF can run on.NET, though just on Windows, not Linux or Mac. If you have an existing.NET Framework application that you desire to run on.NET, then it will certainly require transforming using a Microsoft-provided upgrade aide (more on that particular later). Console applications function well on Linux as well as Mac.
Another difference is the versions of C#. More recent versions of C# are just showing up in.NET, with one of the most recent being C# 11 (presently in Preview), while.NET Structure 4.8 is completely stuck at C# 7.3. It is possible to install C# 8.0 on.NET Framework (as this Heap Overflow concern discusses) yet there are some new attributes such as brand-new nullable characteristics that aren’t sustained.
WinForms on.NET
Throughout the years I’ve developed plenty of WinForms applications; in theory, they must also function in.NET. Nonetheless, I have actually located the designer is something of a work in development as well as sometimes takes a very long time to open. It has been totally redesigned in.NET 6, as this Microsoft article clarifies. It does not really feel fairly as stylish as the designer on.NET Structure.
As part of this post, I created a simple type in a.NET Structure task as well as the exact same in.NET 6, both using one of the most updated Visual Studio 2022 on Windows 11.
System.Drawing
If your WinForms application does any kind of quantity of graphics handling, it’s likely that it uses System.Drawing. This provides accessibility to the Windows GDI+ graphics performance. If you start developing for Linux with.NET, you’ll see that the System namespace no longer includes Attracting. This was among the breaking modifications revealed in the notes for.NET 6 (you can read about it).
Attempt running an application making use of System.Drawing on Linux or Mac and also you’ll get this exception: “System.Drawing.Common is not sustained on non-Windows systems.” There is an arrangement button that lets you hide this exemption on.NET 6 but it will be removed in.NET 7. Microsoft recommends you change libraries to one of ImageSharp, SkiaSharp or
Microsoft.MAUI.Graphics
I transformed an application to use SkiaSharp to create a Bitmap image in RAM and then save it to disk as a.png file. It ran with no problems on both Windows and Linux (Ubuntu 22.04); but altering collections is fairly a pain as well as will take a couple of days or weeks to do. There’s no simple conversion, as the graphics code needs to be reworded.
Update Aide
This is a totally free command line device produced by Microsoft for upgrading.NET Framework jobs to.NET 6. It not only takes care of WinForms as well as WPF projects but also UWP jobs, console applications, ASP.NET MVC sites and.NET Framework class collections. It works for both C# and VB.NET projects. A tutorial regarding the upgrade aide has been provided by Microsoft.
Once mounted you can examine or update the job. Doing the examine command produces a.sarif formatted file. This is short for Static Evaluation Outcomes Interchange Layout. There’s a cost-free Sarif visitor offered below for Visual Studio and an extension for VS Studio Code. It outputs this:
[20:11:27 INF] Running analyzers on WinFormsAppFramework
[20:11:28 INF] Determined 0 diagnostics in project WinFormsAppFramework
[20:11:28 WRN] HighDpiMode needs to embed in Main() instead of app.config or app.manifest– Application.SetHighDpiMode( HighDpiMode.). It is advised to use SystemAware as the HighDpiMode option for far better results.
[20:11:28 INF] Analysis Complete, the record is available at …( snipped).
Running the aide with upgrade displays a collection of actions, starting with backing up the task. Then it refers just pushing 1 to do the following action or 2 to cancel it. When my job was transformed, the only distinction I discovered in code was that the Key() approach had the adhering to call added:
Application.SetHighDpiMode( HighDpiMode.SystemAware);.
It compiled and ran uncreative.
Summary
Needing to update with the assistant suggests that it’s probably something you’ll do just when you actually need to, specifically if it makes use of System.Drawing. I’ve a feeling that a great deal of WinForms and also WPF software application will certainly stay on.NET Structure for some years to find. The benefits of being able to construct applications for Linux as well as Mac won’t occur if it uses WinForms/WPF for UI.
If you wish to develop a GUI C# application for Linux or Mac, after that you’ll need an alternate collection. There are a number of around (Uno, Avalonia and also others), so check out what works for you.