0

I have code like the one in this question, basically a UI-thread that gets updated from another thread and uses InvokeRequired() and Invoke(..). Now, if the method fails in the work part, the debugger stops on the Invoke(..) line -can I make it show me the line where it actually failed like it usually does?

Community
  • 1
  • 1
Niklas Winde
  • 1,761
  • 3
  • 23
  • 33
  • Please pay attention to the suggest prompts when tagging your question. Any tag with a number less than 10 after it's name is probably wrong. Avoid creating new tags. – Joel Coehoorn Jun 09 '09 at 13:52
  • Oh, sorry -I meant visualstudio2008, I actually even chose a suggestion. Must have gotten the space in there by accident. – Niklas Winde Jun 09 '09 at 14:12

2 Answers2

1

Have you tried having the debugger break on exceptions (in the VS menus: Debug -> Exceptions, navigate to "Common Language Runtime Exceptions" and optionally dig down to a specific exception type, check the Thrown check box)? This will cause the debugger to break at the code line where the exception is thrown. I think this works also in multithreaded scenarios.

Fredrik Mörk
  • 155,851
  • 29
  • 291
  • 343
1

What you're likely running into is an issue with Just My Code (JMC). This is a feature of the debugger where it tries to limit items like unhandled exception notification to only code that is owned by the user instead of the framework. Try disabling this feature and breaking on thrown exceptions and that should take you to the source of the problem.

Disabling Just My Code

  • Go to Tools -> Options
  • Navigate to Debugger -> General
  • Uncheck the Just My Code option
JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454