MAUI blazor an unhandled error has occurred
Asked Answered
F

3

7

If there is an error in the program, I get "An unhandled error has occured". With Blazor Web assembly I can open the developper tools in the browser to get the details of what happend. This is not possible in Blazor MAUI.

So how can I get the details of the error in Blazor MAUI?

Foresight answered 24/4, 2022 at 19:30 Comment(3)
Just use F12 to open the dev tools.Sorbitol
F12 has no effectForesight
What operating system? It works on my Blazor Maui apps. click in the window, then press F12Sorbitol
M
19

There is a way to "remotely inspect" your app using the browser developer tool (F12). First, check if you added the AddBlazorWebViewDeveloperTools in your MauiProgram.cs

#if DEBUG
    builder.Services.AddBlazorWebViewDeveloperTools();
#endif

Run your App and open a new tab in your browser (outside the emulator) and type:

  • For Chrome: chrome://inspect
  • For Edge: edge://inspect

Wait a little and you will see an "inspect" button like below: enter image description here

And you can even navigate in your App from there: enter image description here

Mouton answered 16/6, 2022 at 21:23 Comment(1)
and how would you go about doing this if the app was in debug on a physical android device connected via usb ?Ignazio
D
7

When you get this type of error:

Pic of Error

First click the screen with your mouse, then hit F12. Then select the Console link a top of Dev Tools Form.

Dev Tools Pic

Disuse answered 12/8, 2022 at 21:38 Comment(2)
This is the right & simplest answer.Adria
How is that related? Question is about emulator and simulator and not we developmentGuttural
G
4

You can open the developer tools by pressing ctrl + shift + i (or cmd + shift + i for Mac) when you have focus inside the web view.

Note: you need to enable the developer tools.

builder.Services.AddMauiBlazorWebView();

// enable the developer tools
builder.Services.AddBlazorWebViewDeveloperTools();
builder.Services.AddBlazorWebView();
Gelatinize answered 29/4, 2022 at 0:12 Comment(5)
This does not work in MAUI.Christensen
it does for me. I am using it right now. you may need to add the tools, I will update my answer with this information.Gelatinize
@Gelatinize but I need to debug this on an iOS and android deviceWoolly
@Woolly this solution will work when using a simulator...not sure how debugging works with real devices to be honest. Haven't messed with this in a while.Gelatinize
Also does not work for me when running a MacCatalyst app (using Visual Studio for Mac 17.5.6)Pavyer

© 2022 - 2024 — McMap. All rights reserved.