Say I have the following code:
async void buttonClick(object sender, RoutedEventArgs e)
{
await nested1();
}
async Task nested1()
{
await nested2();
I think I may have discovered the answer to my question.
First, I uncheck System.Exception
under the "Thrown" column in the exceptions window (Ctrl+Alt+E). I do this because I don't want Visual Studio to break on all exceptions, only unhandled ones.
Second, I keep "Just my code" enabled in the debugger options.
Now, when the debugger breaks, it will break here:
as per the screenshot in my question. But if I inspect the call stack:
I can actually see where the exception originated from (in nested3()
, line 46). If I click this entry in the call stack window, Visual Studio will jump to the correct line, and the "Locals" window will even show me the values of local variables in that frame. Cool! I think this is what I wanted.
It's not possible.
Why is it not possible?
Because it's not done yet. async
is still getting better tooling support with every release, and I do expect this behavior to be added sooner or later.
How can I identify the line of code that has thrown the exception, whether that be a throw statement of my own code, or a framework method call that has thrown an exception?
Visual Studio 2013 does have the ability to view asynchronous causality stacks in the debugger. If you want similar behavior at runtime, then you can use my async diagnostics package.