question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Application.UnhandledException strips Message and StackTrace

See original GitHub issue

Describe the bug

When the Microsoft.UI.Xaml.Application.UnhandledException event is raised, the exception it captures has no stack trace, and the message has reverted to the default message for the exception. This makes it very difficult to determine the cause of an unhandled exception.

Steps to reproduce the bug

Microsoft.UI.Xaml.Application.Current.UnhandledException += (sender, e) => {
    var stackTrace = e.Exception.StackTrace;   // set a breakpoint and examine here
}

Then go throw an exception somewhere, such as in a button click. Set a breakpoint and debug the app.

Expected behavior

The stack trace should be populated. Instead, it is null.

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.0.3

Windows app type

  • UWP
  • Win32

Device form factor

Desktop

Windows version

Windows 11 (21H2): Build 22000

Additional context

Testing from within VS 2022 17.3.0 Preview 1.1 from within a MAUI app.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
mattjohnsonpintcommented, May 31, 2022

FYI - I also tried in a UWP application and the exception comes through with all properties intact, so the issue is specific for WinUI 3.

1reaction
Scottj1scommented, Sep 6, 2022

App.UnhandledException fix will be available in Windows App SDK 1.2 Preview 2.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Need to handle uncaught exception and send log file
When my app creates an unhandled exception, rather than simply terminating, I'd like to first give the user an opportunity to send a...
Read more >
c# - How can we avoid showing the literal path in ...
When our in-house developed application (C#, ASP.NET) is throwing an exception, it displays a stack trace that contains path information like C ...
Read more >
Application.UnhandledException Event (Windows.UI.Xaml)
The UnhandledException event arguments expose an exception object through the Exception property. However, the type, message, and stack trace of this ...
Read more >
An unhandled exception occurred during the execution of ...
So start with the stack trace which will tell you the file, method, and line that caused the exception. Then you can look...
Read more >
What is an Unhandled Exception, and How to Catch All C# ...
An exception is a known type of error. An unhandled exception occurs when the application code does not properly handle exceptions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found