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); } }
Mattias
source share