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.
So far only on Windows
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.
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 aka.ms/dotnet/hot-reload; However, this page is not yet up to date, because not all the change options mentioned there have already been implemented.
Performance and size
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.