Visual Studio 2015 调试器因 DebuggerHidden 函数的已处理异常而停止

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

我希望调试器在以下时间停止:

到目前为止没有问题,我可以让 Visual Studio 2015 像那样工作。但是,当具有 DebuggerStepThroughDebuggerHidden 属性的函数内部发生 handled 异常时,调试器会停止调用此函数的位置。

我找不到解决此问题的方法。我不记得 Visual Studio 2010 年或 2013 年的这种行为。我搜索过它,但没有发现任何人询问同样的问题。

编辑: 我试过 DebuggerNonUserCode,结果是一样的。它说 "Exception thrown"。不,不是的!

我的设置:

您可以在 VS2015 中使用 DebuggerNonUserCode 属性而不是 DebuggerStepThrough 或 DebuggerHidden 属性,因为它们之间存在一些小差异:

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

更新:

我在使用 VS2015 时遇到了与您相同的问题。我发现它与调试选项有关,请在 TOOLS->Options->Debugging 下启用选项 "Use Managed Compatibility Mode"。再调试一下。

MSDN 文章 Using the DebuggerNonUserCode Attribute in Visual Studio 2015 解释了 DebuggerNonUserCode 的作用 为什么它不忽略异常。

这是由于 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”.

这会带来很大的性能提升,因为:

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”.

可以通过更新 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.0_Config\Debugger\Engine /v AlwaysEnableExceptionCallbacksOutsideMyCode /t REG_DWORD /d 1

您必须进行试验,看看什么更重要,忽略异常或更好的调试器性能。