views:

53

answers:

2

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?

+1  A: 

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
+1  A: 

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
This did not work unfortunatly
Niklas Winde