I’ve seen in multiple projects a kind of catch all exception to catch all unexpected exception so the app won’t crash, i see this usually with :
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(myUnexpectedExhandler);
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(threadExHandler);
Is this a good or bad practice.
Catching exceptions at the top level of your project is fine and correct. There, you can do things such as log it, report the details back to your team, etc. Exceptions should definitely be published somewhere if at all possible — that helps a lot in terms of developing a rock-solid product (see Jeff Atwood’s blog post “Exception-Driven Development” for a commentary on this).
What is bad practice is catching exceptions inappropriately further down the call stack. The only time you should catch an exception is when you know exactly what to do with it. Certainly, you should never, ever, ever, ever silently swallow exceptions.