How to have a global exception handling in dll in

2019-02-24 11:45发布

问题:

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.

Thanks.

回答1:

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.

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