Exemplo n.º 1
0
        internal static void SubmitCrashReport()
        {
            StringBuilder diag = new StringBuilder();

            diag.AppendLine("Application:\n" + Application.ProductName);
            diag.AppendLine("\nVersion:\n" + Application.ProductVersion);
            diag.AppendLine("\nDate:\n" + DateTime.Now.ToUniversalTime().ToString() + " UTC");
            diag.AppendLine("\nOperating System:\n" + Environment.OSVersion.VersionString);
            diag.AppendLine("\nPlatform:\n" + (IntPtr.Size == 8 ? "64" : "32") + " bit");
            diag.AppendLine("\nRunning As:\n" + (isElevated ? "Administrator" : "Standard User"));
            diag.AppendLine("\nFramework Version:\n" + FrameworkVersion);
            diag.AppendLine("\nUAC Enabled:\n" + UACEnabled);

            ReportListener reporter = Trace.Listeners.Cast <TraceListener>().Where(tl => tl is ReportListener).FirstOrDefault() as ReportListener;

            diag.AppendLine("\nDebug Log:\n" + string.Join("\n", string.Join("\n", reporter.Messages.Select(m => string.Format("<{0}> {1}: {2}", m.Timestamp, m.Category, m.Message)).ToArray())));

            UploadReport("http://factormystic.net/prosnap/feedback/report.php", Crash.Gzip(diag.ToString()));
        }
Exemplo n.º 2
0
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            try
            {
                var InnermostException = e.ExceptionObject as Exception;
                Trace.WriteLine(string.Format("Unhandled Exception at '{0}':\n{1}", InnermostException.TargetSite, InnermostException), string.Format("Program.CurrentDomain_UnhandledException [{0}]", System.Threading.Thread.CurrentThread.Name));

                DumpTraceReport();

                if (!Debugger.IsAttached)
                {
                    Crash.SubmitCrashReport();
                }

                new CrashReportForm().ShowDialog();
                Application.Exit();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(string.Format("Unhandled Exception... Exception:\n{0}", ex), string.Format("Program.CurrentDomain_UnhandledException [{0}]", System.Threading.Thread.CurrentThread.Name));
            }
        }