dotnet / dotnet/maui

Support Global Exception Handling Mechanism for .NET MAUI

Open
#5,535 14 comments 40 reactions 1 assignee Claimed by @StephaneDelcroix View on GitHub
area-core-hosting partner/cat 😻 t/enhancement ☀️
Dominant language
C#
Stars
23.3k
Forks
2k
Avg merge
1d 15h
Merged PRs (30d)
290

Description

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

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

Currently this is possible in WPF/WinForms via:

```csharp
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

- [x] https://github.com/dotnet/aspnetcore/pull/40765
- [x] https://github.com/microsoft/microsoft-ui-xaml/issues/5221
- [x] https://github.com/dotnet/maui/issues/4441
- [ ] MAUI: enable AppDomain.CurrentDomain.UnhandledException for MAUI based applications to support a global exception handling mechanism

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.