AppDomain UnhandledException

后端 未结 2 1717
慢半拍i
慢半拍i 2021-01-17 23:41

I am working on a C# project and want to make use of the UnhandledException event to catch any exceptions I may have missed in my project (hoping there won\'t be any but to

2条回答
  •  没有蜡笔的小新
    2021-01-18 00:18

    Assuming that all of your projects are running in the same appdomain, this will work correctly. We have this exact code encapsulated in a common DLL that is shared among numerous applications.

    An additional suggestion: if this is used in Windows Forms applications, you probably also want to add a handler for System.Windows.Forms.Application.ThreadException. This serves as a backstop when, for example, someone forgets to add exception handling to a control event.

提交回复
热议问题