Reputation: 16111
I'm trying to save myself endless keystrokes and mouse clicks while debugging two process's that communicate with each other.
Question: So given an external System.Diagnostics.Process instance that I created, how can I programmatically (i.e. externally) attach the debugger to it?
I've looked in the System.Diagnostics.Debugger class, but it seems to have methods to only attach the debugger to the currently running process, NOT an external process.
Thanks for your help.
Upvotes: 2
Views: 1468
Reputation: 2696
If you can edit the code inside the second process, call Debugger.Launch();
from there.
However if you can't:
Assuming the file you are excecuting is a managed assembly, you could create a wrapper assembly that first prompts you with attaching, and then starts the actual exe.
using System;
using System.Diagnostics;
class Program
{
static void Main(string[] args)
{
Debugger.Launch();
AppDomain.CurrentDomain.ExecuteAssembly(@"C:\\path\to\file.exe");
}
}
Upvotes: 1