Please let me know what steps I need to follow when my application crashes and closes showing the dialog containing “Don’t send” and “Send error report” buttons.
What can I possibly do other than looking at the event viewer to solve this?
Thanks
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 could add a
try/catch/finallyconstruct around yourMain()entry method’s body.For WinForms, you can add a
ThreadExceptionhandler, just before Application.Run(), to catch exceptions thrown in WinForms UI event handlers:All other unhandled exceptions can be caught using:
But it’s worth mentioning that this only allows you to log/report the exception – you cannot prevent the application from closing once you exit this final handler.
Visual Studio can also be configured to break on first chance exceptions, and external debuggers (like WinDbg with managed SoS extensions) can catch first-chance exceptions too (http://www.codeproject.com/KB/debug/windbg_part1.aspx).
Also, use a logging framework like log4net to add useful logging to your app and dump exception information before the application closes.