Edit: Visual Studio 2015\'s new exception window is so much faster than the old dialog that I no longer care as much about using a keyboard shortcut for i
First i initalized a timer an then i call the command Exception.Debug. The timer hit, when the modal dialog is openend. If you use Win 7 with deactivated UAC SendKeys with ALT-Key will fail...i don't know why.
i played a little bit...try this (VS2010 EN):
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Imports System.Runtime.InteropServices
'...
Private WithEvents t As Timers.Timer
Private Sub t_Elapsed(ByVal ee As Object, ByVal dd As Timers.ElapsedEventArgs) Handles t.Elapsed
t.Stop()
' Tastatureingaben simulieren
System.Windows.Forms.SendKeys.SendWait("{DOWN}")
System.Threading.Thread.Sleep(1500) ' Pause wichtig zum Laden des Exceptionbaums
System.Windows.Forms.SendKeys.SendWait("%t")
System.Windows.Forms.SendKeys.SendWait("{ENTER}")
End Sub
Public Sub toggleCLRExceptions()
If DTE.Solution.Count <= 0 Then
MsgBox("Nicht ohne geöffnete Solution!")
Exit Sub
End If
' Timer wird benötigt, da der Dialog Modal ist
' und weitere Befehle im Macro werden erst nach beenden des Dialogs ausgeführt
t = New Timers.Timer()
t.Interval = 0.5
t.Start()
DTE.ExecuteCommand("Debug.Exceptions")
'System.Windows.Forms.SendKeys.SendWait("^%e") ' alternativ: STRG+ALT+e
System.Threading.Thread.Sleep(200)
If isCLRExceptionsActive() Then
MsgBox("BREAK @CLR-Exception", MsgBoxStyle.Information, "Info")
Else
MsgBox("NO BREAK @CLR-Exception", MsgBoxStyle.Information, "Info")
End If
End Sub
Function isCLRExceptionsActive() As Boolean
' prüft, ob Setting Debug CLR-Exceptions aktiviert/deaktivert ist
Dim dbg As EnvDTE100.Debugger5 = DTE.Debugger
Dim exSettings As ExceptionSettings = dbg.ExceptionGroups.Item("Common Language Runtime Exceptions")
Dim exSetting As ExceptionSetting
Try
exSetting = exSettings.Item("Common Language Runtime Exceptions")
Catch ex As COMException
If ex.ErrorCode = -2147352565 Then
exSetting = exSettings.NewException("Common Language Runtime Exceptions", 0)
End If
End Try
Return exSetting.BreakWhenThrown
End Function
'...