2010-08-11 54 views
9

我正在使用System.Diagnostics.Process對象創建進程,該對象有時會崩潰並且Windows會提供「發送錯誤報告」對話框。我無法控制子進程,但我已經在處理崩潰的情況,如何防止彈出對話框?如何在子進程崩潰時禁止Microsoft錯誤報告對話框

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(); 

回答

7

我覺得它很難做到這一點。報告錯誤是用戶的選擇(我們通過控制面板 - >行動中心 - >問題報告設置(Win 7)來設置)

另外。查看this article from MS Support,其中討論了關於使用某些註冊表項禁用此報告(適用於所有應用程序)。

+0

這是不幸的,但它值得問。 – 2010-08-11 19:10:41

+2

[WER Settings](http://msdn.microsoft.com/zh-cn/library/bb513638%28VS.85%29.aspx)也列出了一些註冊表項,特別是'DontShowUI'。 – 2010-09-03 16:22:52