如何拥有一个全球性的异常处理DLL在C#? [英] How to have a global exception handling in dll in C#?

查看:203
本文介绍了如何拥有一个全球性的异常处理DLL在C#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DLL在C#中没有入口点,所以我需要把code全局异常处理在一个地方,因为这些DLL是在exe文件引用,都没有试图追赶,但也有因为一些错误,它崩溃,并确定我们正在努力创造一个崩溃转储。任何人都可以建议是它做了可行的解决方案,或其他任何东西有许多工作要做。

Dll has no entry point in C#, so i need to put the code for global exception handling in one place as these dlls are referenced in exe and all have there try catch but there are some errors due to which it is crashing and to identify we are trying to create a crash dump. Can anyone suggest is it the feasible solution to do that or anything else has to be done.

感谢。

推荐答案

由于科迪说你应该附上每次调用该DLL在try catch块来处理异常。你的说法是有点混乱,我假设你已经在使用try catch块。如果是这样的话,你可以处理全球性的异常,以及以确保它不是EXE本身抛出异常。

As Cody said you should enclose every call to that dll in a try catch block to handle the exception. Your statement is a bit confusing I am assuming you are already using try catch block. If that's the case you can handle global exceptions as well to make sure it's not the exe itself throwing exception.

例如在Win Form应用程序可以处理的 Application.ThreadException 赶上全球例外。您也可以尝试与处理 AppDomain.Unhandled 事件

For example in Win Form application you can handle Application.ThreadException to catch global exceptions. You can also try with handling AppDomain.Unhandled event

这篇关于如何拥有一个全球性的异常处理DLL在C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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