Create a one-step operation to attach to a process
If you find your debugging session typically involves attaching to a specific process you can save yourself some time in VS 2005 by creating a macro to do it for you.
Here's an example macro that was generated when I attached to calc.exe with the native engine:
Sub AttachToCalc() Try
Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger
Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")
Dim dbgeng(1) As EnvDTE80.Engine
dbgeng(0) = trans.Engines.Item("Native")
Dim proc2 As EnvDTE80.Process2 = dbg2.GetProcesses(trans, "JIMSMACHINE").Item("calc.exe")
Catch ex As System.Exception
Now, invoking this macro through the Macro Explorer will cause the exact same attach to whatever program you originally chose! If you want to make your life even easier you could add this macro to a toolbar by:
You could also create an alias for the macro that you can invoke from the command window as follows:
alias attcalc Macros.MyMacros.RecordingModule.AttachToCalc
Now to attach to calc, all you have to do is type "attcalc" in the command window.
Of course, the macro that is created for you is a very simple skeleton. If you'd like you could modify it to do all sorts of other things, like attach to additional processes, or set a breakpoint or whatever!
You might also want to peruse my Idiot's Guide to Creating and Using VS Macros for more helpful hints.