Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / December 2007

Tip: Looking for answers? Try searching our database.

Attach to process... automatically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ronnie Smith - 04 Dec 2007 00:08 GMT
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
Walter Wang [MSFT] - 04 Dec 2007 03:41 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.