First, I'm sorry for what must be a duplicate post. I cannot seem to narrow my search down enough on SO and google to find what I'm looking for.
I'm currently working in a shop where they like their exceptions to bubble up. When the compiled app goes to test, it's a big pain trying to get the details of the exception (message and stack trace). Windows shows that familiar box that lacks any details what-so-ever.
After rescently spending close to an hour finding out that the test box has the wrong version of crystal reports, I added this simple code everone is probably familiar with.
static void Main(string[] arg)
{
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run( ... );
}
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
MessageBox.Show(e.Exception.ToString());
}
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
MessageBox.Show((e.ExceptionObject as Exception).ToString());
}
This gets the job done, but I'm not allowed to check it in. Is there any way in the app.config or via registry setting to get the CLR to show or log exception details for a compiled .net app?
Thanks in advance for your help.