可以阻止单个应用程序的Microsoft错误报告吗? [英] Can one prevent Microsoft Error Reporting for a single app?

查看:176
本文介绍了可以阻止单个应用程序的Microsoft错误报告吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个非托管C ++应用程序,它使用第三方API来读取CAD文件。在某些损坏的CAD文件,第三方库崩溃,带来了我们的EXE下来。因为这个我们的主要应用程序是一个单独的EXE,这样,它不会受到崩溃的影响。

We have an unmanaged C++ application that utilizes 3rd party APIs to read CAD files. On certain corrupted CAD files, the 3rd party library crashes and brings our EXE down with it. Because of this our main application is a separate EXE and in this way it does not get affected by the crash. Howevever, we end up with annoying Microsoft Error Reporting dialogs.

我不想禁用Microsoft错误报告系统范围。有没有办法关闭单个应用程序的错误报告,如果它崩溃,它会默默崩溃,没有错误弹出对话框?

I do not want to disable Microsoft Error Reporting system wide. Is there a way to turn off error reporting for a single application, so that if it crashes, it crashes silently without error popup dialogs?

推荐答案

是的,有一些你可以做的。在你的main()方法中调用SetUnhandledExceptionFilter()来注册一个回调。当没有人志愿处理异常时,就会在Microsoft WER对话框出现之前调用。

Yeah, there's something you can do. Call SetUnhandledExceptionFilter() in your main() method to register a callback. It will be called when nobody volunteers to handle the exception, just before the Microsoft WER dialog shows up.

在回调中实际做的事情充满了麻烦。程序已经死了,总是,一些令人讨厌的像AccessViolation异常。这通常是由堆腐败。尝试做一些事情,比如显示一个消息框让用户知道是麻烦的时候堆是烤面包。死锁总是隐藏在角落里,准备好只是锁定程序,而没有任何诊断。

Actually doing something in that callback is fraught with trouble. The program has died with, invariably, something nasty like an AccessViolation exception. Which often is tripped by heap corruption. Trying to do something like displaying a message box to let the user know is troublesome when the heap is toast. Deadlock is always lurking around the corner too, ready to just lock up the program without any diagnostic at all.

唯一安全的事情是有一个帮助程序保护你的主要过程。通过在回调中发送一个命名事件来唤醒它。给它它需要一个内存映射文件的异常信息。帮助者可以做任何事情,当它看到事​​件发出信号。包括显示消息,采取minidump。

The only safe thing to do is to have a helper process that guards your main process. Wake it up by signaling a named event in your callback. Give it the exception info it needs with a memory-mapped file. The helper can do pretty much anything it wants when it sees the event signaled. Including showing a message, taking a minidump. And terminating the main process.

这正是Microsoft WerFault助手的工作原理。

Which is exactly how the Microsoft WerFault helper works.

这篇关于可以阻止单个应用程序的Microsoft错误报告吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆