Friday, March 4, 2011

Any have a Visual Studio shortcut/macro for toggling break on handled/unhandled exceptions?

I've been trying to write a macro do do the equivalent of

  1. Hitting Ctrl+Alt+E to bring up the Exceptions window
  2. Toggling the textbox in the 'thrown' column for 'Common Language Runtime Exceptions'
  3. Hitting OK

If I record this, it records only a single line of macro code which doesn't do anything. Anyone know how to do this?

From stackoverflow
  • It's late and I haven't tested it, but does this help?

        Dim dbg As EnvDTE90.Debugger3 = DTE.Debugger
        Dim exSettings As EnvDTE90.ExceptionSettings = dbg.ExceptionGroups.Item("Common Language Runtime Exceptions")
        Dim exSetting As EnvDTE90.ExceptionSetting = exSettings.Item("System.Data")
    
        If exSetting.BreakWhenThrown Then
            exSettings.SetBreakWhenThrown(False, exSetting)
        Else
            exSettings.SetBreakWhenThrown(True, exSetting)
        End If
    
    mcintyre321 : It almost works. With a bit of tinkering I'm sure it would. ta!
  • A similar question was posted and answered here. It works for all CLR exceptions and takes ~1.5s to execute.

    mcintyre321 : thanks. man i wish i'd got 12 upvotes!

0 comments:

Post a Comment