How can I get useful WPF .NET error information from a user's machine?

后端 未结 4 1195
日久生厌
日久生厌 2020-12-15 07:14

I have a WPF application that\'s crashing once I get it onto machines that do not have a development environment installed-- if this is a dupe, I\'m welcome to closing, but

4条回答
  •  有刺的猬
    2020-12-15 07:59

    In addition to Alistair's answer, it's the InnerException that gave me the clues I was looking for:

    public partial class App : Application {
        void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) {
            Exception ex = e.Exception;
            Exception ex_inner = ex.InnerException;
            string msg = ex.Message + "\n\n" + ex.StackTrace + "\n\n" +
                "Inner Exception:\n" + ex_inner.Message + "\n\n" + ex_inner.StackTrace + "\n\n" + 
                Utils.RegistryVersion();
            MessageBox.Show(msg, "Drop Print Batch Application Halted!", MessageBoxButton.OK);
            Utils.MailReport(msg);
            e.Handled = true;
            Application.Current.Shutdown();
        }
    }
    

提交回复
热议问题