我正在使用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();
Run Code Online (Sandbox Code Playgroud)
我认为实现这一目标有点困难.报告错误是用户的选择(我们通过控制面板 - >操作中心 - >问题报告设置(Win 7)进行设置)
也.查看MS支持中的这篇文章,其中讨论了使用某些注册表项禁用此报告(适用于所有应用程序).