Is it possible to catch an exception from anywhere in a console app that would cause the app to terminate? I’m trying to do this without having and try{} catch{} around everything.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use
AppDomain.CurrentDomain.UnhandledExceptionevent which will catch all unhandled exceptions.Also check this thread for reference: .NET Global exception handler in console application
Try – catch in your main will not be able to catch exceptions from other threads, for example.