Catch-all error handling on application level?

前端 未结 5 1888
面向向阳花
面向向阳花 2021-01-19 04:58

I have a WPF form with a couple of buttons, and for each button I have error handling code:

try {bla bla} 
catch(Exception e){
  more bla
}

5条回答
  •  走了就别回头了
    2021-01-19 05:28

    You can subscribe to AppDomain.UnhandledException event (see MSDN) to accomplish this. Ideally, this happens when bootstrapping your application. You can find the AppDomain you're executing in via AppDomain.Current.

提交回复
热议问题