Summary
During App.xaml.cs refactoring, discovered that Application.UnhandledException does not reliably catch exceptions on Uno Platform Skia Desktop targets. This is a known Uno Platform limitation (issue #6569).
Affected Areas
Any code that throws exceptions from:
DispatcherQueue.TryEnqueue callbacks
DispatcherQueueTimer.Tick handlers
- Async event handlers (
async void)
Current Workaround
Critical event handlers should wrap code in try-catch and manually send ExceptionDialogMessage:
someHandler += (s, e) =>
{
try
{
// Code that might throw
}
catch (Exception ex)
{
WeakReferenceMessenger.Default.Send(new ExceptionDialogMessage(
Title: "Error",
Summary: "An error occurred.",
Exception: ex,
Timestamp: DateTimeOffset.Now));
}
};
What Still Works
Application.UnhandledException - fires for some synchronous UI exceptions
AppDomain.CurrentDomain.UnhandledException - catches fatal exceptions (app still crashes)
TaskScheduler.UnobservedTaskException - fires on GC for unobserved task exceptions
References
- Uno Platform issue #6569 - Exception handling inconsistencies (still open for Skia targets)
- Uno.Sdk version: 6.5.0-dev.100
Summary
During App.xaml.cs refactoring, discovered that
Application.UnhandledExceptiondoes not reliably catch exceptions on Uno Platform Skia Desktop targets. This is a known Uno Platform limitation (issue #6569).Affected Areas
Any code that throws exceptions from:
DispatcherQueue.TryEnqueuecallbacksDispatcherQueueTimer.Tickhandlersasync void)Current Workaround
Critical event handlers should wrap code in try-catch and manually send
ExceptionDialogMessage:What Still Works
Application.UnhandledException- fires for some synchronous UI exceptionsAppDomain.CurrentDomain.UnhandledException- catches fatal exceptions (app still crashes)TaskScheduler.UnobservedTaskException- fires on GC for unobserved task exceptionsReferences