我可以调整visual studio“抛出异常时中断"吗?以编程方式选择? [英] Can I adjust the visual studio "Break when an exception is thrown" options programmatically?

查看:22
本文介绍了我可以调整visual studio“抛出异常时中断"吗?以编程方式选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简要说明:

在 Visual Studio 2008 中,Debug 菜单有一个 Exceptions... 选项.
单击此按钮时,它会显示抛出异常时中断"对话框,其中我勾选了公共语言运行时异常"旁边的框.

In Visual Studio 2008, the Debug menu has an Exceptions... option.
When clicking this, it brings up the "Break when an exception is thrown" dialog, wherein I tick the box next to "Common Language Runtime Exceptions".

我希望能够以编程方式勾选/取消勾选此框.

I want to be able to tick / untick this box programmatically.

细化:

这会导致调试器在抛出任何 CLR 异常时中断(而不是在它被捕获并重新抛出时),因此这非常适合进行故障排除.

This causes the debugger to break when any CLR exception is thrown (not when it's caught and re-thrown), so this is great for troubleshooting.

问题是,它捕获了所有 CLR 异常,而 .NET 框架恰好在内部抛出并捕获了一堆异常,这些异常也被捕获了.这会导致调试器因一堆异常而中断,我真的不关心这些异常,因为它们是框架内部的,不是问题.
WCF 在这方面特别很糟糕,幸运的是,我的应用程序到处都在使用 WCF.

The problem is, it catches all CLR exceptions, and the .NET framework happens to throw and catch a bunch of exceptions internally, which also get caught. This causes the debugger to break on a bunch of exceptions which I really don't care about as they are internal to the framework and not a problem.
WCF is particularly bad at this, and as fortune has it, my app uses WCF all over the place.

我想做的是关闭复选框,一旦我的应用程序启动(并通过 WCF 连接阶段和所有内部异常),然后打开它,以中断所有例外情况从现在开始.

What I'd like to do, is have the checkbox turned off, and once my app has started up (and got past the WCF connection phase and all the internal exceptions), then have it turned on, to break on all exceptions from now on.

  • 我知道我不必对所有 clr 例外"一概而论,但是可能的例外列表大约有 2 英里长,滚动浏览并选择您想要的那些(然后是什么)需要很长时间如果我错过了一些).

推荐答案

这并没有直接解决您的问题,但是有一个方便的和弦 ctrl-D + E 可以调出调试异常对话框.Ctrl+Alt+E 会做同样的事情.

This doesn't address your question directly, but there's a handy chord ctrl-D + E that brings up the debugging exceptions dialog. Ctrl+Alt+E will do the same thing.

这篇关于我可以调整visual studio“抛出异常时中断"吗?以编程方式选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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