Created
November 29, 2011 22:16
-
-
Save bwiggs/1406827 to your computer and use it in GitHub Desktop.
DebuggingMacros.vb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' original code from Ingo Rammer (http://weblogs.thinktecture.com/ingo/2011/02/attach-to-process-macro-for-visual-studio-2010.html) | |
' ===== Create the Macro ===== | |
' 1. Tools > Macros > Macro IDE | |
' 2. Right Click MyMacros > Add > Add Module | |
' 3. Paste in the code below: | |
' 4. Rename the Macro file DebuggingMacros | |
' ==== Add Macros to Debug Toolbar ==== | |
' Enable the debug toolbar | |
' Click the dropdown on the far right and click "Add or Remove buttons" > click "Customize" | |
' Click "Add Command" | |
' Select Macro on the left panel | |
' Find the macro in the list on the right | |
' Click "ok" | |
' Click "Modify Selection" and rename the button | |
' * repeat for nunit macro | |
Public Module DebuggingMacros | |
Public Sub AttachToWebServer() | |
Dim AspNetWp As String = "aspnet_wp.exe" | |
Dim W3WP As String = "w3wp.exe" | |
If Not (AttachToProcess(W3WP)) Then | |
If Not AttachToProcess(AspNetWp) Then | |
System.Windows.Forms.MessageBox.Show("Can't find web server process") | |
End If | |
End If | |
End Sub | |
Public Sub AttachToNunitAgent() | |
Dim NunitAgent As String = "nunit-agent.exe" | |
If Not AttachToProcess(NunitAgent) Then | |
System.Windows.Forms.MessageBox.Show("Can't find nunit-agent process") | |
End If | |
End Sub | |
Public Function AttachToProcess(ByVal ProcessName As String) As Boolean | |
Dim Processes As EnvDTE.Processes = DTE.Debugger.LocalProcesses | |
Dim Process As EnvDTE.Process | |
Dim ProcessFound As Boolean = False | |
For Each Process In Processes | |
If (Process.Name.Substring(Process.Name.LastIndexOf("\") + 1) = ProcessName) Then | |
Process.Attach() | |
ProcessFound = True | |
End If | |
Next | |
AttachToProcess = ProcessFound | |
End Function | |
End Module |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment