Blazor also runs on the desktop in .NET 6 Preview 3

Microsoft has released a third preview of .NET 6. In conjunction with the associated SDK, the company is delivering two new NuGet packages: Microsoft.AspNetCore.Components.WebView.WindowsForms and Microsoft.AspNetCore.Components.WebView.Wpf. These implement a new control element BlazorWebView for Windows Forms or Windows Presentation Foundation (WPF), which enables a Blazor-based single-page web application to be integrated into a desktop application. The Blazor application does not run in a web server or a WebAssembly VM, but in the same .NET 6 process as the desktop program; thus it has full access to all local resources of the client.

A Blazor web application in Windows Forms has full access to the file system and other resources of the Windows operating system.

The operating system requirement is currently Windows .NET 6 Preview 3 SDK and installing the WebView2 control. If this is missing, you only see the message “System cannot find the file specified” when starting the application – without any further information on the missing file. If you don’t want to use Visual Studio Code but the “big” Visual Studio, you need it Version 16.10 Preview 1.

Microsoft had already announced in September 2019 that it would also offer the .NET-based single-page web app framework Blazor as a hybrid solution in desktop applications and at that time two prototypes in connection with GitHubs Electron and as pure .NET application provided. The pure .NET application is now to become part of .NET 6 under the title “Blazor Desktop”.

Microsoft does not want to limit Blazor Desktop to Windows, but also an integration of Blazor into the cross-platform UI framework .NET .NET Multi-Platform App UI (MAUI) (see message on Preview 2) in upcoming preview versions Successor to Xamarin.Forms, deliver.

The third preview version also offers hot reloading at development time for Blazor and ASP.NET Core-based web applications. The dotnet watch tool, which completely recompiled and restarted the application when changes were made to the program code, now works incrementally and therefore faster. The condition of the components is also retained, which makes development work much more fluid.

With hot reloading, the states of the components are retained after a change to the layout and / or program code.

Developers can still use the keyboard shortcut at any time Ctrl + R Force a full restart of the web application at the console running dotnet watch. With regard to the possible changes to the code, Microsoft refers to; However, this page is not yet up to date, because not all the change options mentioned there have already been implemented.

Further improvements in .NET 6 Preview 3 mainly concern the execution speed, for example when checking and casting interfaces, handling structs and in the just-in-time compiler RyuJIT. Details are described in a Blog entry by .NET program manager Rich Lander.

ASP.NET Core 6 Preview 3 has significantly reduced the size of some JavaScript files. The Razor Compiler has been accelerated by dispensing with separate assemblies for the Razor user interfaces (Views, Pages and Components). When deploying to the IIS web server, the shadow copy procedure is now also available in ASP.NET Core that existed in classic ASP.NET; This means that binary files can also be exchanged if they are currently loaded into RAM. Daniel Roth describes further innovations in ASP.NET Core 6 Preview 3 in a separate blog post.


To home page

Leave a Reply

Your email address will not be published. Required fields are marked *