How to have a global exception handling in dll in C#?

前端 未结 1 498
一生所求
一生所求 2021-01-21 05:20

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

1条回答
  •  清酒与你
    2021-01-21 05:50

    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

    0 讨论(0)
提交回复
热议问题