Search code examples
c#visual-studio-2015visual-studio-debugging

Visual Studio 2015 debugger stops for a handled exception of a DebuggerHidden function


I want the debugger to stop when:

  • A handled or unhandled exception occurs.
  • An unhandled exception occur in a function that has a DebuggerStepThrough or DebuggerHidden attibute. Debugger should stop where this function is being called.

There is no problem so far, I could able to make Visual Studio 2015 work like that. However when an handled exception occurs inside a function that has a DebuggerStepThrough or DebuggerHidden attibute, the debugger stops where this function is being called.

I couldn't find a way to fix this. I don't remember this behavior on Visual Studio 2010 or 2013. I've searched about it, and did not find anybody asking about the same issue.

Edit: I have tried DebuggerNonUserCode, result is the same. It says "Exception thrown". No it does not! enter image description here

My settings: enter image description here


Solution

  • You could use the DebuggerNonUserCode Attribute instead of the DebuggerStepThrough or DebuggerHidden attribute in VS2015 since there are a few small differences between them:

    https://blogs.msdn.microsoft.com/visualstudioalm/2016/02/12/using-the-debuggernonusercode-attribute-in-visual-studio-2015/

    Update:

    I get the same issue as yours using the VS2015. I found that it would be related to on debugging option, please enable the option "Use Managed Compatibility Mode" under TOOLS->Options->Debugging. Debug it again.

    enter image description here