在Visual Studio中的任何方法,而不是特定的异常投掷突破?

在Visual Studio中的任何方法,而不是特定的异常投掷突破?

问题描述:

有一个编译器和调试器的属性,这将使调试器不在一个特定的异常的即使的调试>>例外菜单下的投掷打破我已经告诉它打破任何时候CLR例外的是扔?

Is there a pragma or debugger attribute which will allow the debugger to not break on the throwing of a specific exception even though under the Debug >> Exceptions menu I've told it to break when any CLR Exceptions are throw?

在一般同时发展我喜欢它打破异常调试时,这样我可以立即对其进行检查。有时,它是已知的code此块偶尔抛出异常,我已经有一个try-catch处理它在某些孤立的情况下。请参见回答这个问题那里的共识是的try-catch是最正确的情况。

In general while developing I like to have it break on exceptions while debugging so that I can immediately inspect them. Sometimes there are some isolated cases where it is known that this block of code occasionally throws exceptions and I've handled it in with a try-catch. See the answer to this question where the consensus was that try-catch is the most correct situation.

我希望能够在方法(这是类似于System.Diagnostics.DebuggerHiddenAttribute)刚刚忽略了方法抛出的异常设置一个属性。

I'd like to be able to set an attribute on the method (something analogous to System.Diagnostics.DebuggerHiddenAttribute) which just ignores any exceptions thrown in the method.

顺便说一句,我目前在Visual Studio 2008中遇到此,但我猜有两种所有版本的答案或者没有。

BTW, I'm currently experiencing this in Visual Studio 2008, but I'm guessing there is either an answer for all versions or none.

直接回答可以调试菜单的例外菜单项下找到。这是一个每个解决方案/项目设置。 (工具>选项>调试是一个系统范围的设置。)请参阅帮助主题的 Visual Studio调试器,如何:打破时抛出一个异常的在http://msdn.microsoft.com/en-us/library/d14azbfh.aspx了解详情。例外对话框允许你设置抛出异常或异常进入调试器。

The direct answer can be found under Exceptions menu item of the Debug menu. This is a per solution/project setting. (Tools > Option > Debugging is a system-wide setting.) See the help topic Visual Studio Debugger, How to: Break When an Exception is Thrown at http://msdn.microsoft.com/en-us/library/d14azbfh.aspx for details. The Exceptions dialog allows you to set which exceptions are thrown or which exceptions break into the debugger.

我觉得我得到更多的使用了 DebuggerStepThrough 属性。

I find I get more use out of the DebuggerStepThrough attribute.

在一般情况下,我离开抛出默认的例外(调试>例外用户未处理的检查,将抛出未经检查),并添加了在那里我不感兴趣方法 DebuggerStepThrough 属性通过加强我也不是有意的任何异常被该方法中抛出。我很少用 DebuggerHidden ,并获得在库code与 DebuggerNonUser code 更多的使用。

In general, I leave throwing exceptions to the default (Debug > Exceptions user-unhandled checked and Thrown unchecked) and add the DebuggerStepThrough attribute for methods where I am not interested in stepping through nor am I interested in any exceptions being thrown within that method. I rarely use DebuggerHidden, and get more use with DebuggerNonUserCode in library code.