Hi, is there any automatic way (e.g. F5) with VS2005 that I can launch a
debugging session, followed by an Attach to a certain process (after a delay
of say, 10 seconds) ?
So I am trying to Attach to a process which runs as a result of the
debugging session executable, without having to Attach manually.
Many thanks,
Ronnie
Hi Ronnie,
I think you can use Macro in VS2005 to do this. In the "Samples" macro
project, you will find a module named "VSDebugger", there's a sample macro
called "AttachToCalc" that demonstrates how to attach to calc.exe:
' This subroutine attaches to calc.exe if it is running.
Sub AttachToCalc()
Dim attached As Boolean = False
Dim proc As EnvDTE.Process
For Each proc In DTE.Debugger.LocalProcesses
If (Right(proc.Name, 8) = "calc.exe") Then
proc.Attach()
attached = True
Exit For
End If
Next
If attached = False Then
MsgBox("calc.exe is not running")
End If
End Sub
You can use DTE.Debugger.Go(false) to enter debug mode and wait for 10
seconds, then use above approach to attach your target process.
Hope this helps.
Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Ronnie Smith - 04 Dec 2007 17:19 GMT
Walter,
Thank you for your answer. Unfortunately macros stopped working
in my VS2005 about two months ago (I think after a service pack was
installed and I haven't been able to use them since).
Could I write another .NET program (C#) and do all that's necessary
in there?
Thanks again,
Ronnie
> Hi Ronnie,
>
[quoted text clipped - 36 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
Ronnie Smith - 04 Dec 2007 19:41 GMT
As a follow up - I re-installed the VS2005 SP1
(VS80sp1-KB926601-X86-ENU.exe)and my macros are working again.
> Walter,
>
[quoted text clipped - 49 lines]
> >
> > This posting is provided "AS IS" with no warranties, and confers no rights.
Walter Wang [MSFT] - 05 Dec 2007 07:59 GMT
Hi Ronnie,
Thanks for your update. Please feel free to let me know if there's any
questions about the macro.
Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Justin Chase - 05 Dec 2007 15:29 GMT
I personally hate macros, so I'm not sure if you're using managed code
but if you are then you can attach a debugger to your process directly
from within code:
#if DEBUG
System.Diagnostics.Debugger.Launch();
#endif