c# – 调试时是否可以完全忽略catch块?

我在WinForms(.net 3.5)中工作,并具有以下代码行:
HitTestResult result;
     try
     {
        result = this.HitTest( e.X,e.Y,ChartElementType.DataPoint);
     }
     catch(Exception e)
     {
        //This happens,we don't care!
     }

我无法控制HitTest是否抛出异常,但如果是这样,我绝对不在乎.

是否可以禁用我的IDE停止在这个SPECIFIC catch块?我明白我可以禁用它可能抛出的System.FormatException(从Debug->例外菜单,但这是一种过度的杀戮.

谢谢!

解决方法

您可以使用 DebbugerStepThrough属性跳过该行.从MSDN:

Instructs the debugger to step through the code instead of stepping
into the code.

例如:

[DebuggerStepThrough]
public void MyMethod()
{
    HitTestResult result;
    try
    {
        result = this.HitTest(e.X,ChartElementType.DataPoint);
    }
    catch (Exception e)
    {
        //This happens,we don't care!
    }
}

相关文章

在要实现单例模式的类当中添加如下代码:实例化的时候:frmC...
1、如果制作圆角窗体,窗体先继承DOTNETBAR的:public parti...
根据网上资料,自己很粗略的实现了一个winform搜索提示,但是...
近期在做DSOFramer这个控件,打算自己弄一个自定义控件来封装...
今天玩了一把WMI,查询了一下电脑的硬件信息,感觉很多代码都...
最近在研究WinWordControl这个控件,因为上级要求在系统里,...