Is there a way to log or intercept First Chance Exceptions

前端 未结 3 1170
抹茶落季
抹茶落季 2020-12-19 05:10

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

3条回答
  •  醉酒成梦
    2020-12-19 05:46

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

    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.

提交回复
热议问题