Here's a few Visual Studio Macros that I can't live without at the moment. They're somewhat pieced together from bits I found online and customized for my needs. Thanks to whoever you are!
In order:
- Locates the currently open file in the Solution Explorer panel.
- Attaches debugger to a service.
- Attaches debugger to an open Silverlight window.
(Ugh! VB - Whoever thought it was a good idea to write whole applications in this stuff?)
Imports System
Imports EnvDTE100
Imports System.Diagnostics
Public Module AttachDebugger
Public Sub LocateCurrentFileInSolutionExplorer()
' Suggest binding to: Alt+L Alt+L
DTE.ExecuteCommand("View.TrackActivityinSolutionExplorer")
DTE.ExecuteCommand("View.TrackActivityinSolutionExplorer")
DTE.ExecuteCommand("View.SolutionExplorer")
End Sub
Public Sub DebugMyService()
Dim p As EnvDTE.Process
For Each p In DTE.Debugger.LocalProcesses
If p.Name.ToLower().EndsWith("myservice.exe") Then
p.Attach()
Exit Sub
End If
Next
MsgBox("Could not find ReadinowSvc.exe")
End Sub
Sub DebugSilverlight()
'Thanks to http://www.dllshepherd.net/2011/05/silverlight-attach-to-process-shortcut.html
Try
Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger
Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")
Dim dbgeng(1) As EnvDTE80.Engine
dbgeng(0) = trans.Engines.Item("Silverlight")
For Each process As EnvDTE80.Process2 In dbg2.GetProcesses(trans, Environment.MachineName)
If process.Name.Contains("iexplore.exe") Then
For Each program As EnvDTE.Program In process.Programs
If program.Name.Contains("Silverlight") Then
process.Attach2(dbgeng)
End If
Next
End If
Next
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
End Module
No comments:
Post a Comment