Make Visual Studio ignore exceptions?

前端 未结 7 2187
一个人的身影
一个人的身影 2021-01-12 02:27

I\'m using exceptions to validate a control\'s input in Silverlight 4. When I throw an invalid input exception, VS 2010 displays the popup and stops the program. I ignore th

7条回答
  •  天命终不由人
    2021-01-12 02:37

    I got [System.Diagnostics.DebuggerHidden()] to work if I also selected

    Debug > Options > Debugging > General > Enable Just My Code (Managed only).

    I access the Excel object model a lot, and I really like to be able to run the debugger and catching all exceptions, since my code normally is exception less. However, the Excel API throws a lot of exceptions.

    // [System.Diagnostics.DebuggerNonUserCode()]  works too
    [System.Diagnostics.DebuggerHidden()]
    private static Excel.Range TrySpecialCells(Excel.Worksheet sheet, Excel.XlCellType cellType)
    {
        try
        {
            return sheet.Cells.SpecialCells(cellType);
        }
        catch (TargetInvocationException)
        {
            return null;
        }
        catch (COMException)
        {
            return null;
        }
    }
    

提交回复
热议问题