WPF/WinForms Blazor WebView Exception Handling #40765
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WPF/WinForms Blazor WebView Exception Handling
Currently exceptions within Blazor code are not fatal to the underlying application, resulting in inconsistent behavior and a challenging debugging experience for developers.
Description
Updated exception handling mechanism to throw exceptions from the platform dispatch context instead of directly, so they can be consumed in WPF/WinForms applications using the standard
AppDomain.CurrentDomain.UnhandledException
API.Other details
Unhandled Exception
yellow bar within the webview. This had a serialized exception stack trace with limited additional information, making debugging the error more challenging.Helpful blogs on error handling within WPF:
Please note, this is specifically for WPF/WinForms scenarios. It's not entirely clear if there's a canonical way we can do this on MAUI yet (related discussion dotnet/maui#653).
Fixes dotnet/maui#4441
Customer Impact
Provides developers with improved insights on application errors, and increased control over exception handling. When an exception occurs, the app will crash and close, instead of remaining open in a corrupted state.
Regression?
Risk
Changes are specific to WebView for use with Blazor Hybrid. The intention of this change set is to guarantee the application DOES crash.
Verification
Packaging changes reviewed?