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.ProcessNam eArray) {
AttachProcess(P rocessName);
}
}
private void AttachProcess( string processName) {
bool IsAttached = ProcessIsAttach ed(processName) ;
if (! (IsAttached) ) {
AttachProcessIf RunningLocal(pr ocessName);
}
}
private bool ProcessIsAttach ed( string processName) {
foreach ( EnvDTE.Process process in
this.applicatio nObject.Debugge r.DebuggedProce sses){
string CurrentProcess = process.Name.To Upper().ToStrin g();
string[] arr = CurrentProcess. Split(new char[]{'\\'});
CurrentProcess = arr[arr.Length - 1];
if (processName.To Upper() == CurrentProcess)
return true;
}
return false;
}
private void AttachProcessIf RunningLocal( string processName) {
foreach ( EnvDTE.Process process in
this.applicatio nObject.Debugge r.LocalProcesse s) {
string CurrentProcess = process.Name.To Upper().ToStrin g();
string[] arr = CurrentProcess. Split(new char[]{'\\'});
CurrentProcess = arr[arr.Length - 1];
if (processName.To Upper() == CurrentProcess) {
System.Threadin g.Thread.Sleep( 100);
process.Attach( );
break;
}
}
}
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.ProcessNam eArray) {
AttachProcess(P rocessName);
}
}
private void AttachProcess( string processName) {
bool IsAttached = ProcessIsAttach ed(processName) ;
if (! (IsAttached) ) {
AttachProcessIf RunningLocal(pr ocessName);
}
}
private bool ProcessIsAttach ed( string processName) {
foreach ( EnvDTE.Process process in
this.applicatio nObject.Debugge r.DebuggedProce sses){
string CurrentProcess = process.Name.To Upper().ToStrin g();
string[] arr = CurrentProcess. Split(new char[]{'\\'});
CurrentProcess = arr[arr.Length - 1];
if (processName.To Upper() == CurrentProcess)
return true;
}
return false;
}
private void AttachProcessIf RunningLocal( string processName) {
foreach ( EnvDTE.Process process in
this.applicatio nObject.Debugge r.LocalProcesse s) {
string CurrentProcess = process.Name.To Upper().ToStrin g();
string[] arr = CurrentProcess. Split(new char[]{'\\'});
CurrentProcess = arr[arr.Length - 1];
if (processName.To Upper() == CurrentProcess) {
System.Threadin g.Thread.Sleep( 100);
process.Attach( );
break;
}
}
}
Comment