Do Visual Studio ignore exceptions?

I use exceptions to test the control in Silverlight 4. When I throw an invalid input exception, VS 2010 displays a popup and stops the program. I ignore this and resume the program, and everything continues normally (since the exception is used to signal a validation error.) Is there a way to mark this exception as ignored?

I follow this tutorial .

+7
c # visual-studio silverlight
source share
7 answers

Debugging → Exceptions → Uncheck

+16
source share

Menu, Debugger, Exceptions ...

In this dialog box, you can remove the checkmark in the thrown column for one exception, for the entire namespace. You can add your own. etc.etc.

+4
source share

I tried to create a general solution so that I could use any call where I want the debugger not to stop if I get an exception, but I didn’t get it working.

Any ideas are welcome. But the obvious solution would be the VS2010 debugger to support the DoNotBreakIfException flag :-)

My idea was to replace code like

srng = TrySpecialCells(sheet, cellType); 

by

 srng = ExcelTry(() => sheet.Cells.SpecialCells(cellType)); 

where ExcelTry is

 [System.Diagnostics.DebuggerNonUserCode()] [System.Diagnostics.DebuggerHidden()] private static T ExcelTry<T>(Func<T> call) { try { return call(); } catch (TargetInvocationException) { return default(T); } catch (COMException) { return default(T); } } 
+3
source share

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

Debugging> Options> Debugging> General> Include only my code (only for managed).

I turn to the Excel object model a lot, and I really like being able to run the debugger and catch all exceptions, as my code is usually an exception. However, the Excel API throws many 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; } } 
+2
source share

You can disable some throw block surrounded in the block

 #if !DEBUG throw new Exception(); /// this code will be excepted in the debug mode but will be run in the release #endif 
+1
source share

Assuming this is the property above that throws the exception, it looks like it should work, but apparently not: [System.Diagnostics.DebuggerHidden()] :

  private String name; [System.Diagnostics.DebuggerHidden()] public String Name { get { return name; } set { if (String.IsNullOrWhiteSpace(value)) { throw new ArgumentException("Please enter a name."); } } } 
+1
source share

In Visual Studio 2015, there is an exception settings window for this.

Debugging> Windows> Exclusion Settings

0
source share

All Articles