本文介绍了混合本机/托管可执行文件中的最终托管异常处理程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用/ clr编译的MFC应用程序,我正在尝试为未捕获的托管异常实现最终处理程序。对于本机异常,覆盖中覆盖MFC主线程的足够低级别的点。 code>。例如, CWinApp :: Run 。这可能是一个很好的解决方案,但我没有考虑任何性能或稳定性方面的问题。在保释之前,您将有机会使用调用堆栈进行登录,并且可以避免默认的Windows不受约束的异常行为。

In an MSDN forum question on this topic it was suggested to override a sufficiently low-level point of the main MFC thread in a try ... catch (Exception^). For instance, CWinApp::Run. This may be a good solution but I haven't looked at any perf or stability implications. You'll get a chance to log with a call stack before you bail and you can avoid the default windows unahndled exception behavior.

推荐答案

浏览互联网,您会发现需要安装一个过滤器,以获取非托管异常,这些异常将过滤器传递到您的AppDomain。来自:

Taking a look around the internets, you'll find that you need to install a filter to get the unmanaged exceptions passing the filters on their way to your AppDomain. From CLR and Unhandled Exception Filters:

这篇关于混合本机/托管可执行文件中的最终托管异常处理程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 21:47
查看更多