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 2005

Tip: Looking for answers? Try searching our database.

attaching VS debugger programmatically?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kezsel - 08 Nov 2005 04:41 GMT
Hi,
The automation object model in Visual Studio has some objects one can use
to remotely control basic debug operations as breakpoints,
stepping through the code  etc. I haven't however found anything that would
enable me to attach to the right process on the right machine
- the sort of functionality you get inside Processes dialog  
( Debug->Processes from main menu).
Any suggestions will be greatly appreciated.
Thanks.
Dustin Campbell - 08 Nov 2005 15:18 GMT
> The automation object model in Visual Studio has some objects one can
> use to remotely control basic debug operations as breakpoints,
> stepping through the code  etc. I haven't however found anything that
> would enable me to attach to the right process on the right machine
> - the sort of functionality you get inside Processes dialog  
> ( Debug->Processes from main menu).

Hi,

The automation model has support for for attaching to other processers.
Try using the LocalProcesses property on the Debugger interface.

using EnvDTE;

public void OnConnection(object applicationObject, ext_ConnectMode
connectMode, object addInInstance, ref Array custom)
{
 DTE lDTE = (DTE)applicationObject;
 
 // Find my process...
 foreach (Process lLocalProcess in lDTE.Debugger.LocalProcesses)
 {
   if (lLocalProcess.Name.IndexOf("notepad.exe") >= 0)
   {
     lLocalProcess.Attach();
     break;
   }
 }
}

Signature

Best Regards,
Dustin Campbell
Developer Express, Inc

Dustin Campbell - 08 Nov 2005 15:24 GMT
> The automation model has support for for attaching to other
> processers.

I meant "processes" of course. :-)

Signature

Best Regards,
Dustin Campbell
Developer Express, Inc

kezsel - 08 Nov 2005 15:52 GMT
Hi Dustin,

Thanks for your response. It solves half of my problem.
There are situations when I need to programmatically control
debugging of a process on a remote host. Do you happen to know how to select
target host through automation?

Thanks,
kezsel

> > The automation model has support for for attaching to other
> > processers.
>
> I meant "processes" of course. :-)
Dustin Campbell - 10 Nov 2005 17:24 GMT
> Thanks for your response. It solves half of my problem.
> There are situations when I need to programmatically control
> debugging of a process on a remote host. Do you happen to know how to
> select target host through automation?

You can do this in Visual Studio 2005 with the Debugger2.GetProcesses()
method that is available in EnvDTE80. AFAIK, there isn't support for
this in Visual Studio 2003. To use Debugger2, just cast DTE.Debugger to
it like this:

using EnvDTE;
using EnvDTE80;

private DTE2 m_DTE;

Debugger2 lDebugger = (Debugger2)m_DTE.Debugger;

These interfaces are documented in the Visual Studio help.

Signature

Best Regards,
Dustin Campbell
Developer Express, Inc

kehlar - 07 Dec 2005 18:50 GMT
Could you clarify this: if I'm using VS 2005 to develop an add-in for VS
2003, I should still be able to use the Debugger2 class to attach the
debugger to a remote machine right? The DTE matters on the developing IDE,
not the IDE the add-in runs in?

Thanks.

> You can do this in Visual Studio 2005 with the Debugger2.GetProcesses()
> method that is available in EnvDTE80. AFAIK, there isn't support for
[quoted text clipped - 9 lines]
>
> These interfaces are documented in the Visual Studio help.
Dustin Campbell - 07 Dec 2005 18:56 GMT
> Could you clarify this: if I'm using VS 2005 to develop an add-in for
> VS 2003, I should still be able to use the Debugger2 class to attach
> the debugger to a remote machine right? The DTE matters on the
> developing IDE, not the IDE the add-in runs in?

Actually, you can't use VS 2005 to develop an add-in for VS 2003
because VS 2003 only hosts .NET Framework 1.1. Your assemblies built
against Framework 2.0 will not execute properly in VS 2003.

Debugger2 is in the EnvDTE80.dll assembly which only ships with VS 2005
and will not run in VS 2003.

Signature

Best Regards,
Dustin Campbell
Developer Express, Inc

kehlar - 07 Dec 2005 19:16 GMT
Thanks for the reply. That's too bad because I really need to implement this
attaching a debugger to a remote process feature on VS 2003.

> > Could you clarify this: if I'm using VS 2005 to develop an add-in for
> > VS 2003, I should still be able to use the Debugger2 class to attach
[quoted text clipped - 7 lines]
> Debugger2 is in the EnvDTE80.dll assembly which only ships with VS 2005
> and will not run in VS 2003.
Dustin Campbell - 07 Dec 2005 19:18 GMT
> Thanks for the reply. That's too bad because I really need to
> implement this attaching a debugger to a remote process feature on VS
> 2003.

AFAIK, there isn't a way to do this from an add-in in VS 2003. In fact,
this missing area of extensibility is one of the reasons that Debugger2
exists in VS 2005.

Signature

Best Regards,
Dustin Campbell
Developer Express, Inc


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.