在 Visual Studio 2015 中,DebuggerStepThrough 不再传递异常? [英] In Visual Studio 2015 DebuggerStepThrough doesn't pass over exceptions anymore?

查看:23
本文介绍了在 Visual Studio 2015 中,DebuggerStepThrough 不再传递异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在早期版本的 Visual Studio 中,您可以使用 [DebuggerStepThrough] 属性来忽略由于某种原因无法避免的特殊方法中的异常(例如网络异常或解析失败).(请参阅此主题:不要停止调试器在抛出并捕获异常时)

In earlier versions of Visual Studio you could use the [DebuggerStepThrough] attribute to ignore exception in a special method which for some reason cannot be avoided (network exceptions e.g. or maybe failing parsings). (See this Thread: Don't stop debugger at THAT exception when it's thrown and caught)

现在 Visual Studio 向我显示调用函数处的异常,即使它已经被捕获并处理.

Now Visual Studio shows me the exception at the calling function without the attribute even though it's already caught and processed.

示例:

    static void Main(string[] args)
    {
        ExceptionalMethod();
    }
    [DebuggerStepThrough]
    static void ExceptionalMethod()         
    {
        try
        {
            throw new Exception("BAM");
        }
        catch 
        { }
    }

此代码不应在 VS 2013 或更低版本中停止.与 DebuggerHidden 的行为相同.

This code should not stop in VS 2013 or lower. Same behaviour with DebuggerHidden.

有什么新技巧可以忽略那个异常吗?不忽略该类型课程的所有例外情况?

Is there a new trick to ignore that very one exception? Without ignoring all exceptions of that type of course?

推荐答案

由于调试 .NET 代码时的有益性能改进",Microsoft 停用了该功能.

Microsoft deactivated the feature due to "beneficial performance improvement when debugging .NET code".

在 Visual Studio 2015 Update 2 中,可以通过更改注册表项来打开该功能/关闭性能改进.

In Visual Studio 2015 Update 2 it's possible to turn the feature on/the performance improvement off by changing a registry key.

在命令行中输入以下内容:

Enter this into your command line to do that:

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

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

这篇关于在 Visual Studio 2015 中,DebuggerStepThrough 不再传递异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆