How many times have you done some web development and used following method to attach your Visual Studio Debugger to w3wp.exe (a.k.a. Debug > Attach to Process –method):
And then you scroll the long list and find your w3wp.exe and press attach:
I’ll bet that you have done that a lot :-) At least I have.
Let’s create macro that does that very same thing but so that you don’t have to take your fingers of the keyboard.
First open up Macro Explorer (using View > Other windows > Macro Explorer or just hit Alt-F8). Then open up example AttachToCalc macro under Samples > VSDebugger:
Right click and select edit:
Copy contents of that and create new macro under My Macros:
And give it a name MyVSDebugger. Then paste the source code to it. Then modify the process name from calc.exe to w3wp.exe and remove the Exit For. You should have something like this left:
Public Module MyVSDebugger
' This subroutine attaches to w3wp.exe:
Dim attached As Boolean = False
Dim proc As EnvDTE.Process
For Each proc In DTE.Debugger.LocalProcesses
If (Right(proc.Name, 8) = "w3wp.exe") Then
attached = True
If attached = False Then
MsgBox("Couldn't find w3wp.exe")
Now you should have this kind of view at the Macro Explorer
Now let’s add keyboard shortcut for our macro from Tools
Just find your new macro and set focus to Press shortcut keys
field and press your favorite keyboard shortcut and press Assign
and then press OK
You might have another command already using that combination but you can override it if you like.
Now we’re ready to use that. If you want to build your solution you can Ctrl-Shift-B and if you want to attach to w3wp.exe you’ll just press Ctrl-Shift-V. This is extremely handy if you have Post-Build event nicely set.
Anyways... Happy hacking!