我正在使用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();
答案 0 :(得分:7)
我认为实现这一目标有点困难。报告错误是用户的选择(我们通过控制面板设置 - >操作中心 - >问题报告设置(Win 7))
另外。查看this article from MS Support,其中讨论了使用某些注册表项禁用此报告(适用于所有应用)。