Skip to content

Version 1.7 regression: Exception thrown from an async method crashes the app and won't be caught by the unhandledException event #10447

@HotCakeX

Description

@HotCakeX

Describe the bug

This is a regression in version 1.7 where an exception thrown from an async method crashes the entire app even if unhandled exceptions are handled by the App class.

Steps to reproduce the bug

When this method is run as a result of a click from the UI, it will crash the entire app. (It works fine if the method is not async).

private async void BrowseForFilesSettingsCard_Click(object sender, RoutedEventArgs e)
{
	throw new InvalidOperationException("test");
}

even though the App class is set to capture it

this.UnhandledException += App_UnhandledException;

private async void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e)
{
	Logger.Write(ErrorWriter.FormatException(e.Exception));	
	e.Handled = true;
	await ShowErrorDialogAsync(e.Exception);
}

Expected behavior

The unhandled exception event handler in the app class must catch it and log the error.

This problem doesn't happen in version 1.6.250228001

Screenshots

No response

NuGet package version

Windows App SDK 1.7.0: 1.7.250310001

Packaging type

Packaged (MSIX)

Windows version

Windows 11 version 24H2 (22621, October 2024 Update)

IDE

Visual Studio 2022-preview

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Crashwhenever user reports a crash or app freezearea-ErrorHandlingIssues related to error reporting and debugging

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions