如何从单独的进程监视应用程序崩溃 [英] How can I monitor an application crash from a separate process

查看:169
本文介绍了如何从单独的进程监视应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.net应用程序,偶尔会因以下Windows错误之一而崩溃:

I have a certain .net application that occasionally crashes with one of the following windows errors:

[application name] has encountered a problem and needs to close. We are sorry for the inconvenience. 或者 [application name] has stopped working

我想从另一个.net进程监视此应用程序,防止显示默认的Windows错误报告对话框,并执行我自己的错误处理.

I want to monitor this app from another .net process, prevent showing the default windows error report dialog, and do my own error processing.

有没有办法检测到另一个应用程序崩溃了?

我可以阻止或隐藏默认错误对话框吗?

一些背景信息:我确实有崩溃的应用程序的代码,如有必要,我可以对其进行更改.但是,崩溃是由第三方非托管程序集引起的,该程序集覆盖了一些内存并使应用程序处于不可恢复的状态.简单的try-catch块不足以防止崩溃.这就是为什么我要监视和处理来自单独进程的错误.

Some background information: I do have the code for the crashing app, and I can change it if necessary. However the crash is caused by a third party unmanaged assembly, which overwrites some memory and leaves the app in an unrecoverable state. A simply try-catch block is not enough to prevent the crash. This is why I want to monitor and handle the error from a separate process.

推荐答案

该对话框是Windows错误报告(WER)的功能.

The dialog box is a function of Windows Error Reporting (WER).

有没有一种方法可以检测到其他应用程序崩溃了?

Is there a way I can detect that the other app has crashed?

有很多选项,从需要过程中发出某种心跳消息的服务到启用损坏的状态异常的捕获,以启用公司WER服务器. (下面的链接)

There are plenty of options, from a service that requires some kind of heartbeat message from the process, to enabling catching of corrupted state exceptions, to enabling a corporate WER server. (link below)

[C]我可以阻止还是隐藏默认的错误对话框?

[C]an I prevent or hide the default error dialog?

WER配置文档包含有关从自动对话框中排除进程的信息.

The WER configuration documentation has information about excluding a process from the automatic dialog.

特别是注册表项:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\
        Windows Error Reporting\ExcludedApplications\[Application Name]

(HKCU具有相似的键)

不幸的是,如果这是访问冲突,那么您的工作就做得很好.到将异常转移到WER时,整个堆栈已被炸毁,并且内存已损坏.

Unfortunately, if it's an access violation, you're pretty well hosed. By the time that the exception has made it to WER the entire stack is blown, and the memory is already corrupt.

禁用应用程序的内置错误报告,还将阻止自动创建小型转储,这可能会有所帮助,即使不能解决直接问题,也可以提供弹药来说服供应商修复其dll.

Disabling the built in error reporting for your application, will also prevent the automated creation of minidumps, which may be helpful, if not in solving the direct issue, providing ammunition for use convincing the vendor to fix their dll.

如果供应商不愿意或无法解决问题,则可以复制资源管理器处理Shell扩展的方式,并在单独的过程中托管组件.这样,当它崩溃时,只会浪费其他进程的内存.您必须编写一个包装程序才能与之通信.

If the vendor is unwilling or unable to fix the problem, you could copy the way Explorer handles shell extensions, and host the component in a separate process. That way, when it crashes, it only trashes the memory of the other process. You'd have to write a wrapper to allow you to communicate with it.

这篇关于如何从单独的进程监视应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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