Is there anything similar to the MyApplication_UnhandledException for an user control in VB?
I would like to have a central point where to catch all unhandled exceptions of a user control, without propagating the exception to the application that uses the user control.
I made some test raising an exception in a method of my user control where there is no try/catch code (of course in the true project all methods have a try/catch block).
The exception was caught by MyApplication_UnhandledException event of the application using the user control.
But this is too “far” from the point where the exception happens and in worst case the user should restart the application.
I would like to realize a behaviour for the user control in order that if the user control fails, the exception is not propagated till the application, but just caught at user control level.
Any suggestion? Thank you.
Edit: I forgot to tell that I am talking about WinForm
No, there really isn’t. There is an exception handler for the forms threads, but this is also global (i.e. all forms participate).
Your only real option is to add appropriate try/catch blocks throughout.