New .NET 9 Templates for Blazor Hybrid, .NET MAUI

Microsoft's fifth preview of .NET 9 nods at AI development while also introducing new templates for some of the more popular project types, including Blazor Hybrid and .NET MAUI.

Somehow neither the release notes nor the accompanying Preview 5 discussions contain the word "Copilot," but even so Microsoft managed to lead off Preview 5 news with "enhanced AI capabilities," basically more methods exposed by TensorPrimitives and Tensor<T> functionality.

"TensorPrimitives and the new Tensor<T> type expand AI capabilities by enabling efficient encoding, manipulation, and computation of multi-dimensional data," said Microsoft of tensors, described as multidimensional arrays that serve as the cornerstone data structure of AI development. Updated versions of these types are available in the latest prerelease version of the System.Numerics.Tensors package.

Meanwhile, new and updated templates are available for popular framework project types, including ASP.NET Core for web development and .NET MAUI for cross-platform mobile development. The latter also allows for desktop development, something not offered by its predecessor, Xamarin.Forms. Thus Preview 5 is headlined by a new template called ".NET MAUI Blazor Hybrid and Web App" solution, which makes it easier to create a .NET MAUI Blazor Hybrid app and a Blazor web app that share the same UI. Microsoft said the new template shows how to create apps that target Android, iOS, Mac, Windows and web while maximizing code reuse.

.NET MAUI Blazor Hybrid and Web App
[Click on image for larger view.] ".NET MAUI Blazor Hybrid and Web App" (source: Microsoft).

Key features of the new template include:

  • The ability to choose a Blazor interactive render mode for the web app.
  • Automatic creation of the appropriate projects, including a Blazor Web App and a .NET MAUI Blazor Hybrid app.
  • The created projects are wired up to use a shared Razor Class Library that contains all of the UI components and pages.
  • Sample code that demonstrates how to use service injection to provide different interface implementations for the Blazor Hybrid and Blazor Web App. In .NET 8 this is a manual process documented in Build a .NET MAUI Blazor Hybrid app with a Blazor Web App.

Using the new template requires Preview 5 or later of the .NET 9 SDK and the installation of the .NET MAUI workload in Visual Studio.

Other ASP.NET Core highlights include:

In addition to the updated Blazor Hybrid template, other assorted .NET MAUI tweaks in .NET 9 Preview 5 include:

On the data side of things, Microsoft noted an enhanced database provider for Azure Cosmos DB for NoSQL along with minor query translation improvements, specifically including:

  • Optimization of queries using Count != 0 or Count > 0
  • Null semantics for comparison operators
  • Translations for TimeOnly.FromDateTime and TimeOnly.FromTimeSpan

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus


Subscribe on YouTube