You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The legacy C# WinRT projection support for UWP apps wrapped all synchronous calls back into C# code with a try/catch, calling RoOriginateLanguageException and then RoReportUnhandledError on any unhandled exceptions, ensuring they were then routed to the App.UnhandledException handler. This behavior is missing from C#/WinRT projections, causing regressions in Microsoft.Windows.SDK.NET.dll (e.g., Window.Activated) and Microsoft.WinUI.dll (most everything else). Thus, fixes might be required across several repos.
Build, set a BP in the MainWindow's Activated handler and in the App.UnhandledException handler, and debug
When the Activated handler BP hits, set next statement to throw the exception
Expected behavior
In either case above, callback or event, the App.UnhandledException handler should be invoked as it is in a UWP app.
Workarounds
There are a couple workarounds:
User callbacks can be marked 'async' (whether or not they contain any awaits). This causes the CLR to wrap invocations in a try/catch, propagating any caught exceptions through the DispatcherQueueSynchronizationContext. this.Activated += **async** (s, e) => { ... };
User callback code can itself be wrapped in a try/catch to propagate errors:
Describe the bug
The legacy C# WinRT projection support for UWP apps wrapped all synchronous calls back into C# code with a try/catch, calling RoOriginateLanguageException and then RoReportUnhandledError on any unhandled exceptions, ensuring they were then routed to the App.UnhandledException handler. This behavior is missing from C#/WinRT projections, causing regressions in Microsoft.Windows.SDK.NET.dll (e.g., Window.Activated) and Microsoft.WinUI.dll (most everything else). Thus, fixes might be required across several repos.
To Reproduce
For an override callback:
For an event:
Expected behavior
In either case above, callback or event, the App.UnhandledException handler should be invoked as it is in a UWP app.
Workarounds
There are a couple workarounds:
this.Activated += **async** (s, e) => { ... };
The text was updated successfully, but these errors were encountered: