How I found this used Microsoft's Mdbg tools to give me access from the runtime to basic debugging information. The basic form of the code used is as follows:
MDbgEngine mg; MDbgProcess mgProcess; try { mg = new MDbgEngine(); mgProcess = mg.Attach(debugProcess.Id); } catch (Exception ed) { Console.WriteLine("Exception attaching to process " + debugProcess.Id ); throw (ed); } mgProcess.CorProcess.EnableLogMessages(true); mgProcess.CorProcess.OnLogMessage += new LogMessageEventHandler(HandleLogMessage); mg.Options.StopOnLogMessage = true; mgProcess.Go().WaitOne(); bool running = true; Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress); while (running) { try { running =mgProcess.IsAlive; mgProcess.Go().WaitOne(); } catch { running = false; } }
It seems to work quite well for me, in any case, perhaps it will provide a useful template for everyone who ends up in the same boat.
source share