有没有一种方法来记录或拦截第一次机会异常 [英] Is there a way to log or intercept First Chance Exceptions

查看:124
本文介绍了有没有一种方法来记录或拦截第一次机会异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

短,有什么办法里面一个正在运行的程序来检测第一次机会异常?理想情况下,我想记录不可用,一旦catch块接管了最后的异常的更详细的状态信息。

Short of using a profiler, is there any way inside a running program to detect first chance exceptions? Ideally, I would like to record more detailed state information that is not available once the catch block has taken over the final exception.

推荐答案

我在Google上搜寻FirstChanceException,我无法抗拒回答这个两年多后...

I was googling FirstChanceException, and I can't resist answering this more than two years later...

现在,在.NET 4.0中,你可以赶上在AppDomain的FirstChanceException事件。这仅仅是一个事件,所以你不能处理错误,但它似乎是一个很好的,中央的方式来获得对异常是否对其进行处理或没有信息。前一个catch块被允许处理它的FirstChanceException事件被抛出。我还没有发现大量的信息就可以了,但除了微软的文档中,更好的来源之一是<一个href="http://www.mitchelsellers.com/blogs/articletype/articleview/articleid/334/first-chance-exception-event-net-40.aspx">Mitch卖家博客。

Now, in .net 4.0, you can catch the FirstChanceException event of the AppDomain. It is an event only, so you can't handle the error, but it seems to be a good, central way to get information on exceptions whether they are handled or not. The FirstChanceException event is thrown before a catch block is allowed to handle it. I haven't found a lot of information on it, but aside from the microsoft documentation, one of the better sources is Mitch Sellers Blog.

这篇关于有没有一种方法来记录或拦截第一次机会异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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