Photo by Andrew Neel on Unsplash
.NET Desktop Application Development - A Summary
.NET Desktop Development
Hello Hashnoders!
This is my first time, writing an article on Hashnode & please forgive me if it's not in the standard you expect.
Recently, I went through a course on Pluralsight called .NET 6 Desktop Development: Big Picture by Thomas Claudius Huber which is a pretty solid introductory course for choosing the right framework from the plethora of Desktop Development tools provided by Microsoft for .NET. Inspired by the way that the course was structured and the highly coherent narrative of the author, I planned to summarize my learnings in this article.
.NET Desktop Applications Development:
.NET Desktop application development could be classified into two:
.NET Windows Desktop Applications Development
.NET Cross-Platform Applications Development
.NET Windows Desktop Applications Development:
WinForms
WPF
UWP
WinUI Framework
WinForms/Windows Forms:
Was part of .NET 1.0 developed way back in 2002
Makes use of the GDI+(Graphical Design Interface) & Win32 API baked into the Windows Kernel on top of the Microsoft Windows Operating System
Uses C# language for building UI components
Because of Win32 API, WinForms have permission to access the files/folders of Microsoft Windows OS
The GDI+ & Win32 leverage the capabilities of the CPU(Central Processing Unit) of the system to present the UI in WinForms
WPF/Windows Presentation Foundation:
Was part of .NET 3.0 developed in 2006
Makes use of a native component called MILCore(Media Integration Layer Core) & DirectX, which is a framework that makes use of the computer's GPU(Graphics Processing Unit) for drawing the controls
Uses XAML(extensive Application Markup Language) for building UI Components & makes use of an architectural pattern called MVVM(Model View View Model)
Similar to WinForms, WPF sits on top of the Win32 API having permission to access the files/folders of Microsoft Windows OS
Visual Studio itself is an example of a WPF application
WPF & WinForms have been ported to .NET Core 3.0 framework which was developed in 2016. .NET Core framework is developed as an open-source framework by Microsoft to be able to develop & run applications across multiple platforms.
UWP/Universal Windows Platform:
UWP for Windows development was baked into Windows 10 OS that runs on top of the Windows RT(Window RunTime)
UWP uses the XAML UI Framework & XAML Controls for developing Windows applications
UWP hosting model is a sandbox environment with restricted access to Microsoft Windows OS files/folders & each access should be written as part of the UWP application itself
UWP applications could be written using .NET or C++
UWP applications are only meant for Microsoft Windows 10 OS
WinUI Framework/Windows User Interface Framework:
WinUI 2.x:
UWP applications use XAML controls that are tightly coupled to the underlying newer versions of Microsoft Windows OS
To decouple such a dependency, WinUI 2.x was introduced as a Nuget Package
WinUI 2.x contains the XAML controls built-in, so that the UWP applications can leverage this functionality
WinUI 3:
WinUI 3 framework was introduced as a NuGet package with XAML UI Framework & XAML controls built-in
WinUI 3 could be leveraged by WPF & WinForms to modernize the applications
UWP applications could not use WinUI 3 as they are dependent on the XAML framework that's baked into the Microsoft Windows 10 OS
WinUI 3 is the native UI framework for Microsoft Windows 10/11 OS
WinUI framework also uses the Win32 API for accessing files/folders of Microsoft Windows 10/11 OS
Windows App SDK provides a unified API for developing applications on the Microsoft Windows 10/11 OS & WinUI 3 is a part of the Windows App SDK.
.NET Cross-Platform Application Development Tools:
Xamarin
.NET MAUI
Blazor
Open Source Frameworks(Avalonia & Uno Platform)
Xamarin(Before .NET 6):
With the advent of .NET 1.0 in 2002, another framework targeting Linux OS called Mono was developed in 2004
Mono runtime makes use of the .NET BCL(Base Class Library) to develop .NET applications for Linux OS
As iOS & android are based on the Unix kernel as with the Linux OS, Mono was ported to iOS & android as MonoTouch & Mono for Android respectively
The makers of Mono, MonoTouch & Mono for Android founded a company in 2011, known as Xamarin
Once the company was formed, MonoTouch was renamed Xamarin.iOS & Mono for Android was renamed to Xamarin.Android
To unify the Xamarin development across platforms & to avoid the necessity to leverage native classes to achieve native functionality across platforms, Xamarin.Forms were developed in 2014
Xamarin.Forms also support UWP
Xamarin uses XAML & .NET for application development
With Xamarin.Forms, it became possible to develop applications across iOS, Android & Windows
.NET MAUI/.NET Multi-Platform Applications User Interface(Since .NET 6):
Microsoft acquired Xamarin in 2014
Post the release of .NET 6 in 2021, the capabilities of Xamarin.Forms are extended by .NET MAUI
.NET MAUI supports development for targeting iOS, Android, Windows & MacOS
Xamarin.iOS was renamed to .NET for iOS & Xamarin.Android was renamed to .NET for Android
Instead of UWP which had its limitations, .NET MAUI supports the WinUI library
.NET MAUI also uses XAML & .NET for application development
Blazor:
Blazor is Microsoft's framework for building interactive client-side web applications in .NET
Blazor Classification:
Blazor WebAssembly
Blazor Hybrid
Blazor WebAssembly:
Blazor WebAssembly is meant for developing UI components in HTML/CSS with logic in .NET making use of the Blazor framework across platforms
Blazor WebAssembly runs on the .NET runtime of WebAssembly which is a binary instruction format supported by all modern browsers
Blazor WebAssembly runs on the browser element which could be hosted on the Desktop application
WebAssembly is a sandboxed runtime that has restrictions to the OS access
Blazor Hybrid:
Rather than running on the WebAssembly, the Blazor applications could be running on BlazorWebView to leverage the underlying .NET runtime running on top of the OS
This setup is referred to as the Blazor Hybrid as we have a web application (i.e.) Blazor which is hosted within a Desktop application
We have multiple tools that support Blazor for developing desktop applications like .NET MAUI, WPF & WinForms
Open Source Frameworks:
We have 2 popular open-source frameworks for supporting .NET cross-platform application development:
Avalonia
Uno Platform
Avalonia:
Avalonia is an open-source framework which is an extension of WPF leveraging XAML for cross-platform development
Uno Platform:
The Uno platform does not provide options for cross-platform development per se but compiles an existing Windows application, to be able to port it into other platforms
Which framework to use for Desktop Application Development?
It all boils down to the scenario & skill set when it comes to choosing the framework that works for Desktop Application Development.
Please refer below:
Windows Platform:
Skills:
XAML
Tools:
WPF, WinUI
Skills:
.NET
Tools:
WinForms
Cross-Platform:
Skills:
XAML
Tools:
.NET MAUI, Xamarin, Avalonia, Uno Platform
Skills:
HTML/CSS, .NET
Tools:
Blazor