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;
}
}
}
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;
}
}
}