Skip to content

Breakpoint experience unhelpful in WinUI Apps #5441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dotMorten opened this issue May 20, 2025 · 2 comments
Open

Breakpoint experience unhelpful in WinUI Apps #5441

dotMorten opened this issue May 20, 2025 · 2 comments

Comments

@dotMorten
Copy link
Contributor

dotMorten commented May 20, 2025

Describe the bug

When you write code that causes an exception to occur, very often the exception will be shown in App.xaml's UnhandledException handler, instead of where the exception occurred. This significantly slows down the inner developer loop, because extra time is spent trying to figure out where the exception occurred. It can also easily be (mis)interpreted as a bug with the Windows App SDK and not user code, giving a worse impression of the SDK overall.

This is part of these death-by-1000-razor cut issues that makes the developer experience really poor.

Steps to reproduce the bug

  1. Create a new WinUI project.
  2. in MainWindow.xaml.cs add the following code:
        public MainWindow()
        {
            InitializeComponent();
            this.Activated += MainWindow_Activated;    
        }

        private void MainWindow_Activated(object sender, WindowActivatedEventArgs args)
        {
            throw new ArgumentException(); // Imagine you do something here that occasionally causes an exception
        }
  1. Run the application and observe the exception experience:
    Image

Expected behavior

This is the experience I would have preferred, which helps me faster realize the issue and allow me to move on:
Image
That will also give me access to the state in the thread right here and inspect what went wrong.

As a workaround this can be achieved by realizing this is an ArgumentException and turning on first-chance exceptions, but it requires being able to reproduce the issue right then and there with that first-chance break set on, but from the developer's point of view this isn't a first chance, since there is no try-catch.

Also if you repeat this example in WPF, you'll get the correct breakpoint, .

Screenshots

No response

NuGet package version

Windows App SDK 1.8 Experimental 2: 1.8.250515001-experimental2

Packaging type

Packaged (MSIX)

Windows version

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

IDE

Visual Studio 2022

Additional context

No response

@dotMorten dotMorten changed the title Breakpoint experience broken on WinUI Apps Breakpoint experience unhelpful in WinUI Apps May 20, 2025
@RDMacLachlan
Copy link
Member

Thank you @dotMorten

@lhak
Copy link

lhak commented May 23, 2025

I actually see the expected behavior if "enable just my code" is enabled in the debug settings. I had for some reason turned off that setting in the past and in this case I also observe that it goes directly to the unhandled exception handler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants