【发布时间】:2010-08-12 03:40:00
【问题描述】:
我正在使用System.Diagnostics.Process 对象创建一个进程,该对象有时会严重崩溃,Windows 会弹出“发送错误报告”对话框。我无法控制子进程,但我已经在处理崩溃的情况,如何防止弹出对话框?
Process p = new Process();
p.StartInfo.FileName = Path.Combine(avokeHome, @"bin\folderstx.exe");
p.StartInfo.Arguments = "-f" + propertiesFile;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardOutput = true;
p.OutputDataReceived += (sender, e) => { if(!string.IsNullOrEmpty(e.Data)) Console.WriteLine(e.Data); };
p.ErrorDataReceived += (sender, e) => { if(!string.IsNullOrEmpty(e.Data)) Console.WriteLine(e.Data); };
p.EnableRaisingEvents = true;
p.Exited += (sender, e) => { Console.WriteLine("Exited"); };
p.Start();
p.BeginErrorReadLine();
p.BeginOutputReadLine();
【问题讨论】: