This is based on the code found here: http://blog.lavablast.com/post/2008/01/11/Attach-to-Process-with-one-shortcut.aspx
This is tested in Visual Studio 2008 and 2010.
Public Module AttachDebugger Public Sub AttachDebugger() Try Dim count As Integer count = 0 Dim process As EnvDTE.Process For Each process In DTE.Debugger.LocalProcesses If IsTargetedProcess(process) Then process.Attach() count = count + 1 End If Next If count > 0 Then MsgBox("Successfully connected to " & count & " processes.") Else MsgBox("No targeted processes found.") End If Catch ex As System.Exception MsgBox("Error: " & ex.Message) End Try End Sub Private Function IsTargetedProcess(ByVal process As EnvDTE.Process) As Boolean If process.Name.EndsWith("w3wp.exe") Then Return True ElseIf process.Name.EndsWith("aspnet_wp.exe") Then Return True 'List any other processes you might commonly attach to ElseIf process.Name.EndsWith("NServiceBus.Host.exe") Then Return True End If Return False End Function End Module
1 comments:
Like it!
Post a Comment