Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Public Module Module1
'Empty routine that just causes VS to flush its memory to disk
Sub ReleaseMemory()
End Sub
Sub RebuildDocumentationUpwards()
DTE.ExecuteCommand("ReSharper.ReSharper_GotoPrevMethod")
DTE.ExecuteCommand("Tools.SubMain.GhostDoc.RebuildDocumentation")
End Sub
Sub AttachToW3p()
AttachToProcess("w3wp.exe")
End Sub
Sub AttachToLocalWebDev()
AttachToProcess("WebDev.WebServer40.EXE")
End Sub
Sub AttachToMyProcess()
AttachToProcess("MyProcess.exe")
End Sub
Sub AttachToMyProcessScript()
AttachToProcess("MyProcess.exe", True)
End Sub
Private Sub AttachToProcess(ByVal ProcessName As String, Optional ByVal ScriptOnly As Boolean = False)
Try
Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger
Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")
Dim dbgeng(2) As EnvDTE80.Engine
dbgeng(0) = trans.Engines.Item("Script")
If ScriptOnly Then
Array.Resize(dbgeng, 1)
Else
dbgeng(1) = trans.Engines.Item("Managed")
End If
Dim proc2 As EnvDTE80.Process2 = dbg2.GetProcesses(trans, System.Environment.MachineName).Item(ProcessName)
Call proc2.Attach2(dbgeng)
Catch ex As System.Runtime.InteropServices.COMException
Select Case ex.ErrorCode
Case -2147352565
ShowMessage(ProcessName & " is not currently a running process")
Case -1989083106
ShowMessage("You are already attached to " & ProcessName)
Case Else
ShowMessage("Unhandled error message from Attach to process macro")
End Select
Catch ex As System.Exception
MsgBox("Unhandled exception occurred: " & ex.Message)
End Try
End Sub
Private Sub ShowMessage(ByVal message As String)
Call MsgBox(message, MsgBoxStyle.Exclamation, "Attach to process macro")
End Sub
End Module
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Public Module Module1
'Empty routine that just causes VS to flush its memory to disk
Sub ReleaseMemory()
End Sub
Sub RebuildDocumentationUpwards()
DTE.ExecuteCommand("ReSharper.ReSharper_GotoPrevMethod")
DTE.ExecuteCommand("Tools.SubMain.GhostDoc.RebuildDocumentation")
End Sub
Sub AttachToW3p()
AttachToProcess("w3wp.exe")
End Sub
Sub AttachToLocalWebDev()
AttachToProcess("WebDev.WebServer40.EXE")
End Sub
Sub AttachToMyProcess()
AttachToProcess("MyProcess.exe")
End Sub
Sub AttachToMyProcessScript()
AttachToProcess("MyProcess.exe", True)
End Sub
Private Sub AttachToProcess(ByVal ProcessName As String, Optional ByVal ScriptOnly As Boolean = False)
Try
Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger
Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")
Dim dbgeng(2) As EnvDTE80.Engine
dbgeng(0) = trans.Engines.Item("Script")
If ScriptOnly Then
Array.Resize(dbgeng, 1)
Else
dbgeng(1) = trans.Engines.Item("Managed")
End If
Dim proc2 As EnvDTE80.Process2 = dbg2.GetProcesses(trans, System.Environment.MachineName).Item(ProcessName)
Call proc2.Attach2(dbgeng)
Catch ex As System.Runtime.InteropServices.COMException
Select Case ex.ErrorCode
Case -2147352565
ShowMessage(ProcessName & " is not currently a running process")
Case -1989083106
ShowMessage("You are already attached to " & ProcessName)
Case Else
ShowMessage("Unhandled error message from Attach to process macro")
End Select
Catch ex As System.Exception
MsgBox("Unhandled exception occurred: " & ex.Message)
End Try
End Sub
Private Sub ShowMessage(ByVal message As String)
Call MsgBox(message, MsgBoxStyle.Exclamation, "Attach to process macro")
End Sub
End Module
No comments:
Post a Comment