> 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