Support Global Exception Handling Mechanism for .NET MAUI

See original GitHub issue

Discussed in https://github.com/dotnet/maui/discussions/653

<div type='discussions-op-text'>

Originally posted by AmSmart April 5, 2021 With the new host model in .NET Maui, will we get a straightforward way of catching exceptions?</div>

Currently this is possible in WPF/WinForms via:

AppDomain.CurrentDomain.UnhandledException += (sender, error) =>
{
    MessageBox.Show(text: error.ExceptionObject.ToString(), caption: "Error");
};

The ask of this issue is to enable AppDomain.CurrentDomain.UnhandledException for MAUI based applications to support a global exception handling mechanism.

I looked into the Windows MAUI WinUI3 end of things, and there appears to be a potential bug with the DispatcherQueue which prevents the application from being sent to the AppDomain.CurrentDomain.UnhandledException: https://github.com/microsoft/microsoft-ui-xaml/issues/5221

cc/ @hartez @mattleibow

Blazor Hybrid

Cross linking https://github.com/dotnet/aspnetcore/pull/40765 which handles the case of WPF/WinForms in Blazor Hybrid. If there’s a canonical way to do global exception handling (like we have in WinForms/WPF), we need to ensure .NET MAUI Blazor Hybrid is able to integrate with it directly.

Blazor Hybrid MAUI tracking issue: https://github.com/dotnet/maui/issues/4441

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:23
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
emorell96commented, Aug 24, 2022

Any update on this now that MAUI is so close to GA?

4reactions
kfranciscommented, Aug 24, 2022

Ugh! Trying to port, having a hard time because I can’t see what’s going wrong here:

22-06-35ovo-1654099456

Read more comments on GitHub >

github_iconTop Results From Across the Web

MAUI: Global exception handling with error page or snack
I'm trying the new .Net MAUI to build an personnal project. At work we use Flutter and we used a global error handling...
Read more >
Global Exception Handling in .NET 6
In this article, I will discuss different methods of global exception handling in .NET apps. Error handling with try-catch blocks. Try-catch ...
Read more >
How to add Global Exception Handling in .NET 6 and 7
Handle exceptions efficiently with Global Exception Handling in .NET with this step-by-step guide. Full source code is included for free.
Read more >
How to handle exceptions in .net maui blazor app
How can I handle exceptions and store them in a file.
Read more >
Handling and throwing exceptions in .NET
Learn how to handle and throw exceptions in .NET. Exceptions are how .NET operations indicate failure to applications.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found