Visual Studio debugging

  • Thread starter Thread starter Erik
  • Start date Start date
E

Erik

I have written an add in to the IDE that fires an event to check for
processes that have started up that are in a user specified list. If
one of them is found it will attach the debugger to the process. This
works great when the client and my server drone are the same machine,
but as soon as I deploy I can not do this remotely.

Does anybody have any suggestions on how I can enhance this so I can
attach to a remote server process when it starts up?

Hear is the code I am using:

Thanks,
Erik

private void AttachProcesses() {
foreach (string ProcessName in this.ProcessNameArray) {
AttachProcess(ProcessName);
}
}

private void AttachProcess( string processName) {
bool IsAttached = ProcessIsAttached(processName);
if (! (IsAttached) ) {
AttachProcessIfRunningLocal(processName);
}
}

private bool ProcessIsAttached( string processName) {
foreach ( EnvDTE.Process process in
this.applicationObject.Debugger.DebuggedProcesses){
string CurrentProcess = process.Name.ToUpper().ToString();
string[] arr = CurrentProcess.Split(new char[]{'\\'});
CurrentProcess = arr[arr.Length - 1];
if (processName.ToUpper() == CurrentProcess)
return true;
}
return false;
}

private void AttachProcessIfRunningLocal( string processName) {
foreach ( EnvDTE.Process process in
this.applicationObject.Debugger.LocalProcesses) {
string CurrentProcess = process.Name.ToUpper().ToString();
string[] arr = CurrentProcess.Split(new char[]{'\\'});
CurrentProcess = arr[arr.Length - 1];
if (processName.ToUpper() == CurrentProcess) {
System.Threading.Thread.Sleep(100);
process.Attach();
break;
}
}
}
 
Hi Erik,

I found that this post has been posted in several groups. I will reply to
you in the microsoft.public.vsnet.ide.
Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: (e-mail address removed) (Erik)
| Newsgroups:
microsoft.public.vsnet.debugging,microsoft.public.vsnet.general,microsoft.pu
blic.vsnet.ide,microsoft.public.dotnet.languages.csharp,microsoft.public.dot
net.general
| Subject: Visual Studio debugging
| Date: 5 Nov 2003 15:32:17 -0800
| Organization: http://groups.google.com
| Lines: 52
| Message-ID: <[email protected]>
| NNTP-Posting-Host: 143.182.124.1
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google.com 1068075138 23263 127.0.0.1 (5 Nov 2003
23:32:18 GMT)
| X-Complaints-To: (e-mail address removed)
| NNTP-Posting-Date: Wed, 5 Nov 2003 23:32:18 +0000 (UTC)
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!news-out.cwix.com!newsfeed.cwix.co
m!news.maxwell.syr.edu!postnews1.google.com!not-for-mail
| Xref: cpmsftngxa06.phx.gbl microsoft.public.vsnet.general:14254
microsoft.public.vsnet.ide:9067
microsoft.public.dotnet.languages.csharp:197040
microsoft.public.dotnet.general:114529 microsoft.public.vsnet.debugging:4050
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| I have written an add in to the IDE that fires an event to check for
| processes that have started up that are in a user specified list. If
| one of them is found it will attach the debugger to the process. This
| works great when the client and my server drone are the same machine,
| but as soon as I deploy I can not do this remotely.
|
| Does anybody have any suggestions on how I can enhance this so I can
| attach to a remote server process when it starts up?
|
| Hear is the code I am using:
|
| Thanks,
| Erik
|
| private void AttachProcesses() {
| foreach (string ProcessName in this.ProcessNameArray) {
| AttachProcess(ProcessName);
| }
| }
|
| private void AttachProcess( string processName) {
| bool IsAttached = ProcessIsAttached(processName);
| if (! (IsAttached) ) {
| AttachProcessIfRunningLocal(processName);
| }
| }
|
| private bool ProcessIsAttached( string processName) {
| foreach ( EnvDTE.Process process in
| this.applicationObject.Debugger.DebuggedProcesses){
| string CurrentProcess = process.Name.ToUpper().ToString();
| string[] arr = CurrentProcess.Split(new char[]{'\\'});
| CurrentProcess = arr[arr.Length - 1];
| if (processName.ToUpper() == CurrentProcess)
| return true;
| }
| return false;
| }
|
| private void AttachProcessIfRunningLocal( string processName) {
| foreach ( EnvDTE.Process process in
| this.applicationObject.Debugger.LocalProcesses) {
| string CurrentProcess = process.Name.ToUpper().ToString();
| string[] arr = CurrentProcess.Split(new char[]{'\\'});
| CurrentProcess = arr[arr.Length - 1];
| if (processName.ToUpper() == CurrentProcess) {
| System.Threading.Thread.Sleep(100);
| process.Attach();
| break;
| }
| }
| }
|
 
Back
Top