The Task type carries all exceptions to an AggregateException . However, if you use async / await functionality, then when you await a Task , an internal exception is thrown and thrown again, preserving the original stack trace.
VS11 will have better async debugging support, but I don't think you can go as far as you hope. Task is all about concurrent and asynchronous code, and therefore I donโt think it will ever work.
Consider, for example, if you have a Task running in a thread in a thread pool that you are going to await . You can await in the try block to catch an exception from the Task ... or you can await outside the try block, leaving the Task exception unhandled.
The point with this example is that when an exception is thrown, the debugger does not know if the exception will be unhandled. With synchronous code, as soon as an exception is thrown, the stack is checked - and if it is unprocessed, the debugger knows that it is unprocessed and can immediately take special actions (before the stack is even unwound).
So, I do not think that you can do what you want. You can get pretty close to IntelliTrace though (only in VS Ultimate).
source share