简体   繁体   中英

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! 在此处输入图片说明

My settings: 在此处输入图片说明

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.

在此处输入图片说明

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM