子进程崩溃时如何禁止Microsoft错误报告对话框

时间:2010-08-11 18:23:25

标签: c# .net

我正在使用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();

1 个答案:

答案 0 :(得分:7)

我认为实现这一目标有点困难。报告错误是用户的选择(我们通过控制面板设置 - >操作中心 - >问题报告设置(Win 7))

另外。查看this article from MS Support,其中讨论了使用某些注册表项禁用此报告(适用于所有应用)。