MDbgEngine debugger = new MDbgEngine(); debugger.Options.CreateProcessWithNewConsole = true;
// Specify which debug events we want to receive. // The underlying ICorDebug API will stop on all debug events. // The MDbgProcess object implements all of these callbacks, but only stops on a set of them // based off the Options settings. // See CorProcess.DispatchEvent and MDbgProcess.InitDebuggerCallbacks for more details. debugger.Options.StopOnModuleLoad = true; debugger.Options.StopOnException = true;
while (proc.IsAlive) { // Let the debuggee run and wait until it hits a debug event. proc.Go().WaitOne(); object o = proc.StopReason;
// Process is now stopped. proc.StopReason tells us why we stopped. // The process is also safe for inspection. ModuleLoadedStopReason mr = o as ModuleLoadedStopReason; if (mr != null) { Console.WriteLine("Module loaded:" + mr.Module.CorModule.Name); } }
Console.WriteLine("Done!"); }
For console application all work fine, but for winforms application it's stop for endless time at: proc.Go().WaitOne(); How to solve the problem?