Monday, August 10, 2009

Visual Studio macros to attach to web development server

It is very boring to attach debugger to process from menu. With this macros binded on shortcut it can be done in a moment.

  
Sub AttachToDevServer()
Try
Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger
Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")
Dim dbgeng(3) As EnvDTE80.Engine
dbgeng(0) = trans.Engines.Item("T-SQL")
dbgeng(1) = trans.Engines.Item("T-SQL")
dbgeng(2) = trans.Engines.Item("Managed")
Dim proc2 As EnvDTE80.Process2 = dbg2.GetProcesses(trans, "localhost").Item("WebDev.WebServer.EXE")
proc2.Attach2(dbgeng)
Catch ex As System.Exception
MsgBox(ex.Message)
End Try

End Sub

End Sub

0 comments: