In WinForms, we used the following in Main() or some other startup event:
System.Windows.Forms.Application.ThreadException += ExceptionHandler.Handle;
I searched for something similar in WinUI3 (Windows App SDK) and cannot seem to find anything.
Is there a globalized way of throwing up an exception notification for WinUI3?
public App()
{
InitializeComponent();
UnhandledException += App_UnhandledException;
}
private void App_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
// Handle the exception here.
}
According to some issues posted on the GitHub repo, for example this one, it doesn't catch all exceptions though.