Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7181267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:31:20+00:00 2026-05-28T17:31:20+00:00

Visual Studio has a certain feature that makes debugging unhandled exceptions a lot easier:

  • 0

Visual Studio has a certain feature that makes debugging unhandled exceptions a lot easier: it stops on the offending line of code and shows the exception.

It seems that the Task class is designed in such a way that this feature is always suppressed: it catches every exception, and then rethrows a different exception when the task is Waited or finalized.

I know I can have it stop on first-chance exceptions, but this doesn’t always help: imagine that a number of handled exceptions of the same type occur prior to the unhandled one. In this case VS will stop on every non-problematic exception in addition to the one that actually causes the problem.

Another alternative is even less acceptable: just looking at the stack trace of the InnerException: this means that while I know which line caused the exception, I cannot access any of its local state, like I could if the program was actually stopped there.

Can I somehow get the best of both worlds, using the Task class but not having to live with the degraded exception debugging feature set?


Bonus question: does this mean that a null reference exception inside an await block will not cause Visual Studio to stop right there, but will instead stop somewhere else altogether?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:31:21+00:00Added an answer on May 28, 2026 at 5:31 pm

    The Task type does wrap all exceptions into an AggregateException. However, if you’re using the async/await functionality, then when you await a Task, the inner exception is unwrapped and re-thrown, preserving the original stack trace.

    VS11 will have better async debugging support, but I don’t think it’s possible to go as far as what you’re hoping. Task is all about concurrent and asynchronous code, and that’s why I don’t think this will ever work.

    Consider, for example, if you have a Task running on a thread pool thread that you’re going to await. You can await it in a try block to catch an exception from the Task… or you can await it outside of a try block, leaving the Task‘s exception to be unhandled.

    The point with that example is that when the exception is thrown, the debugger doesn’t know if the exception will be unhandled. With synchronous code, as soon as the exception is thrown, the stack is checked – and if it’s unhandled, the debugger knows it is unhandled and can take special action right away (before the stack is even unwound).

    So, I don’t think it’s possible to do what you want. You can get pretty close with IntelliTrace, though (only in VS Ultimate).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realize that Visual Studio has the /P option to generate preprocessed files, but
Visual Studio 2008 has built-in unittesting that was previously only available in the Team
In Visual Studio, a certain project has a designer window open which is crashing
Visual Studio has a plugin that allows one to copy code from any editor
Visual Studio has certainly gone from strength to strength since humble Visual Studio 6
Visual Studio has a way to import, export your color settings. Does Eclipse have
Visual Studio has ways to automatically create a method. For example, you could double
I've been working on some data transformation tasks in SSIS. Visual Studio has gotten
Visual Studio 2008 has the ability to automatically create unit test stubs. I have
When Visual Studio (2005) has Options -> Text Editor -> C/C++ -> Tabs ->

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.