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

别来无恙 提交于 2019-12-11 06:37:48

问题


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!

My settings:


回答1:


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.




回答2:


The MSDN article Using the DebuggerNonUserCode Attribute in Visual Studio 2015 explains what the DebuggerNonUserCode does and why it doesn't ignore exceptions.

This is caused by a performance improvement in VS 2015

when Just My Code is enabled, the debugger no longer gets notified of exceptions that are thrown and handled outside of “your code”.

This leads to a big performance improvement because:

The debugging performance improved because when Just My Code is enabled, the debugger no longer gets notified of exceptions that are thrown and handled outside of “your code”.

This behaviour can be switched off through a registry key introduced with Update 2:

To enable this, run the following command from your command line that will tweak the registry for you:

reg add HKCU\Software\Microsoft\VisualStudio\14.0_Config\Debugger\Engine /v AlwaysEnableExceptionCallbacksOutsideMyCode /t REG_DWORD /d 1

You'll have to experiment and see what is more important, ignoring exceptions or better debugger performance.



来源:https://stackoverflow.com/questions/41964808/visual-studio-2015-debugger-stops-for-a-handled-exception-of-a-debuggerhidden-fu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!