public Debugger LaunchProcess(string commandLine, string workingDirectory) { IDebugClient5 client = CreateIDebugClient(); IDebugControl control = (IDebugControl)client; if (string.IsNullOrEmpty(workingDirectory)) { workingDirectory = Environment.CurrentDirectory; } string env = GetEnvironment(); DEBUG_CREATE_PROCESS_OPTIONS options = new DEBUG_CREATE_PROCESS_OPTIONS(); options.CreateFlags = (DEBUG_CREATE_PROCESS)1; int hr = client.CreateProcessAndAttach2(0, commandLine, ref options, (uint)Marshal.SizeOf(typeof(DEBUG_CREATE_PROCESS_OPTIONS)), workingDirectory, env, 0, DEBUG_ATTACH.DEFAULT); if (hr < 0) { throw new Exception(Debugger.GetExceptionString("IDebugClient::CreateProcessAndAttach2", hr)); } Debugger debugger = new Debugger(client, control); hr = client.SetEventCallbacks(debugger); if (hr < 0) { throw new Exception(Debugger.GetExceptionString("IDebugClient::SetEventCallbacks", hr)); } hr = client.SetOutputCallbacks(debugger); if (hr < 0) { throw new Exception(Debugger.GetExceptionString("IDebugClient::SetOutputCallbacks", hr)); } return(debugger); }