예제 #1
0
        // ReSharper disable once UnusedMember.Local
        // ReSharper disable once UnusedParameter.Local
        private static void BuildFromException(object sender, UnhandledExceptionEventArgs e)
        {
            if (Debugger.IsAttached)
            {
                return;
            }

            CrashReportData report = new CrashReportData(Guid.NewGuid()).AddDefaultData().AddData("exception.txt", e.ExceptionObject.ToString());

            //Log.IsLoggerEnabled = false; //Make sure log object is not used

            try
            {
                string strFile = Path.Combine(Utils.GetStartupPath, "chummerlog.txt");
                using (StreamReader objStream = new StreamReader(strFile, Encoding.UTF8, true))
                    report.AddData("chummerlog.txt", objStream.BaseStream);
            }
            catch (Exception ex)
            {
                report.AddData("chummerlog.txt", ex.ToString());
            }

            //Considering doing some magic with
            //Application.OpenForms
            //And reflection to all savefiles
            //here

            //try to include all settings files
            foreach (string strSettingFile in Directory.EnumerateFiles(Path.Combine(Utils.GetStartupPath, "settings"), "*.xml"))
            {
                string strName = Path.GetFileName(strSettingFile);
                try
                {
                    using (StreamReader objStream = new StreamReader(strSettingFile, Encoding.UTF8, true))
                        report.AddData(strName, objStream.BaseStream);
                }
                catch (Exception ex)
                {
                    report.AddData(strName, ex.ToString());
                }
            }

            report.Send();
            Program.MainForm.ShowMessageBox("Crash report sent." + Environment.NewLine + "Please refer to the crash id " + report.Id);
        }
예제 #2
0
        private static void BuildFromException(object sender, UnhandledExceptionEventArgs e)
        {
            if (Debugger.IsAttached)
            {
                return;
            }

            CrashReportData report = new CrashReportData(Guid.NewGuid()).AddDefaultData().AddData("exception.txt", e.ExceptionObject.ToString());

            Log.Kill(); //Make sure log object is not used

            try
            {
                string strFile = Path.Combine(Application.StartupPath, "chummerlog.txt");
                report.AddData("chummerlog.txt", new StreamReader(strFile).BaseStream);
            }
            catch (Exception ex)
            {
                report.AddData("chummerlog.txt", ex.ToString());
            }

            //Considering doing some magic with
            //Application.OpenForms
            //And reflection to all savefiles
            //here

            //try to include default settings file
            try
            {
                string strFilePath = Path.Combine(Application.StartupPath, "settings", "default.xml");
                report.AddData("default.xml", new StreamReader(strFilePath).BaseStream);
            }
            catch (Exception ex)
            {
                report.AddData("default.xml", ex.ToString());
            }


            report.Send();
            MessageBox.Show("Crash report sent.\nPlease refer to the crash id " + report.Id);
        }