Let’s Make a Blazor hybrid Application!

  

Maui has been out for a while now and I thought I would learn how to create a Blazor hybrid application and see what it is about.

 

There are blog posts and YouTube videos on how to do this so, see the links below. I am not focusing on the step-by-step but on what I learned by doing this exercise. It will help others.

 

Prep Work

        You will need to make sure you have the Maui project templates installed in Visual Studio.
  1.         Go to the VS installer.
    1.       a.     Click the modified button.
  2.        Make sure under the Desktop and UI Development the .Net Multi-platform App UI development is checked, see image.
  3.       If not check it and click modify to install it.

 


 

Create the Project

1.     Open Visual Studio and click on “Create new Project.”
2.     Find the .Net MAUI Blazor App box and click it.
3.     You can pick .Net 6 or higher.

 

Run the Application

You can launch the application the way you normally launch your apps in Visual Studio, F5, click on the tool bar button etc.

The first time you run it you may get a notification that says, “Enable Developer Mode for Windows.” If you got this message, click on the link, and enable debug mode.

 


Once this is done, the application should run.

 

Gotcha

Once you enable debug mode, you may get a notification stating, “The project needs to be deployed before we can debug. Please enable Deploy in the Configuration Manager".

 



You will get this message if your source code is on a mapped drive or even if it is on an external USB drive. From my research, there is no explanation why this happens and the only fix I found was to move my source to my local drive. The drive windows run from. Microsoft stated this is a known issue.

 

Running the application

This is what the application looks like when you run it. As you can see, it is the standard Blazor Project.




 

Anatomy of a Blazor Hybrid Application

If you look at the code, you will see it is a mixture of XMAL and Razor. The XMAL is used to launch Blazor inside a WebView control. Once in the Blazor application, it operates like a normal Blazor application.

 

Summary

I am incredibly excited to be able to run a true desktop client in Blazor. I could do it before using a PWA, but with Maui, I have full access to the desktop. In addition, with some deployment settings, I have an Android and iOS application.

 

The issue with the source code having to be local was disheartening, making the solution seem unfinished, but a small price to see a Blazor app running on the Desktop.

 

 Step by step creating Maui Blazor Hybrid

[source]


Comments

Popular posts from this blog

Yes, Blazor Server can scale!

Blazor new and improved Search Box

Blazor - Cool Blur Loading Page