Visual Studio调试 - 在一个地方忽略异常,而在其他地方打破它? [英] Visual Studio debugging - ignore exception in one place while breaking at it elsewhere?

查看:138
本文介绍了Visual Studio调试 - 在一个地方忽略异常,而在其他地方打破它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些代码在一条特定的行上生成大量的ArgumentExceptions(这是在不同的开发人员的代码中,所以我不能只是改变它),然后被恰当地捕获和处理。



我正在尝试调试在不同部分代码中发生的ArgumentExceptions(然后被捕获和处理,所以我不能只看未处理的异常)



有没有办法忽略来自该特定其他代码行的ArgumentExceptions,同时仍然打破其他地方抛出的ArgumentExceptions?

解决方案

您可能可以执行此操作,但这取决于要调试代码相对于其他开发人员代码的位置,以及是否您可以修改(但不提交更改)到他的代码。



您首先要做的是至少暂时去菜单在Visual Studio中的工具 - > 选项 - > 调试,然后勾选Just My Code框。我认为即使在快递版本中也可以使用,但它可能不是,如果不可用,我恐怕我不得不说的其余部分可能不会有帮助。



无论如何,一旦你打了电话,你将不会再看到不是你的的代码的分钟通知。这意味着来自不在.sln中的程序集的代码,或者代码从 System.Diagnostics [DebuggerNonUserCode] 属性的代码$ c>。然后我通常会使用 [DebuggerNonUserCode] 临时装饰违规方法,直到我完成调试调试所需的内容,然后在检入之前还原这些更改控制。



它不像我想要的那样优雅(我会喜欢一个永远不会打破这个网站的再次复选框在例外助手),但是它比没有更好。



我相信可能还有其他调试器设置可以与Just My Code如何相互作用,所以如果这不适合你让我知道,我会尝试更准确地了解当我这样做时我的设置是什么样的。


I have some code which generates a large quantity of ArgumentExceptions on one particular line (which is in a different developer's code, so I can't just change it), which are then caught and handled appropriately.

I'm trying to debug ArgumentExceptions which are happening in a different section of code (and are then caught and handled, so I can't just look at unhandled exceptions).

Is there some way to ignore the ArgumentExceptions originating from that particular other line of code, while still breaking on ArgumentExceptions which are thrown elsewhere?

解决方案

You might be able to do this, but it depends on how the code you want to debug is located relative to the other developer's code, and whether or not you can modify (but not commit your changes) to his code.

The first thing you'll want to do is, at least temporarily, go to menu Tools -> Options -> Debugging in Visual Studio, and tick the "Just My Code" box. I assume this is available even in Express editions, but it may not be, and if it's not available for you I'm afraid the rest of what I have to say probably won't help.

Anyway, once you have that ticked, you will no longer see break-on-throw notifications for code that isn't "yours." This means code that is from an assembly not in your .sln, or code marked with the [DebuggerNonUserCode] attribute from System.Diagnostics. What I usually do then is temporarily decorate the offending methods with [DebuggerNonUserCode] until I'm done debugging what I need to debug, and then revert those changes before checking in to souce control.

It's not as elegant as I'd like (I'd love a "never break on throws from this site again" checkbox in the exception assistant), but it's better than nothing.

I believe there may be other debugger settings that could interact with how "Just My Code" works, so if this doesn't work for you let me know and I'll try to get a more accurate picture of what my settings look like when I do this.

这篇关于Visual Studio调试 - 在一个地方忽略异常,而在其他地方打破它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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