Search code examples
.netwinformstry-catch

How set exeption executor for all program


I need to set catch(Exeption ex){} for all my program on winforms.

I tried to put a function in try that launches the application, but only errors that occurred in this function are returned. Is there any way to set catch(Exception ex) for the whole program and not for 1 function. I tried use AppDomain.CurrentDomain.UnhandledException but this is not work. Sorry for my bad English


Solution

  • In winforms, exceptions must not hit the UI event loop. You need to catch on a per event-handler basis. There is no global handler.