internal static void ReportUnhandledException(Exception ex, bool willShutDown, bool silently, string tag) { try { var tags = new List <string> { tag }; if (reporting) { return; } reporting = true; var oldReportCrashes = ReportCrashes; if (UnhandledErrorOccured != null && !silently) { ReportCrashes = UnhandledErrorOccured(ReportCrashes, ex, willShutDown); } // If crash reporting has been explicitly disabled, disregard this crash if (ReportCrashes.HasValue && !ReportCrashes.Value) { return; } var customData = new Hashtable(); foreach (var cd in SystemInformation.GetDescription()) { customData[cd.Title ?? ""] = cd.Description; } #if ENABLE_RAYGUN if (raygunClient != null) { ThreadPool.QueueUserWorkItem(delegate { try { raygunClient.Send(ex, tags, customData, Runtime.Version.ToString()); } catch { // If we get here then things have gone really wrong - we can't log anything or // attempt to report anything. Drop any exception that ends up here. } }); } #endif //ensure we don't lose the setting if (ReportCrashes != oldReportCrashes) { PropertyService.SaveProperties(); } } catch { // I don't know if we can/should try to log this. I'm going to guess that we don't want to // and can't safely call any LoggingService.Log methods anyway in case we'd recurse, though // the 'reporting' boolean should take care of that. } finally { reporting = false; } }
internal static void ReportUnhandledException(Exception ex, bool willShutDown, bool silently, string tag) { var tags = new List <string> { tag }; if (reporting) { return; } reporting = true; try { var oldReportCrashes = ReportCrashes; if (UnhandledErrorOccured != null && !silently) { ReportCrashes = UnhandledErrorOccured(ReportCrashes, ex, willShutDown); } // If crash reporting has been explicitly disabled, disregard this crash if (ReportCrashes.HasValue && !ReportCrashes.Value) { return; } var customData = new Hashtable(); foreach (var cd in SystemInformation.GetDescription()) { customData[cd.Title ?? ""] = cd.Description; } #if ENABLE_RAYGUN if (raygunClient != null) { ThreadPool.QueueUserWorkItem(delegate { raygunClient.Send(ex, tags, customData, Runtime.Version.ToString()); }); } #endif //ensure we don't lose the setting if (ReportCrashes != oldReportCrashes) { PropertyService.SaveProperties(); } } finally { reporting = false; } }
internal static void ReportUnhandledException(Exception ex, bool willShutDown, bool silently, string tag) { try { var tags = new List <string> { tag }; if (reporting) { return; } reporting = true; var oldReportCrashes = ReportCrashes; if (UnhandledErrorOccured != null && !silently) { ReportCrashes = UnhandledErrorOccured(ReportCrashes, ex, willShutDown); } // If crash reporting has been explicitly disabled, disregard this crash if (ReportCrashes.HasValue && !ReportCrashes.Value) { return; } lock (customCrashReporters) { foreach (var cr in customCrashReporters.Concat(AddinManager.GetExtensionObjects <CrashReporter> (true))) { cr.ReportCrash(ex, willShutDown, tags); } } //ensure we don't lose the setting if (ReportCrashes != oldReportCrashes) { PropertyService.SaveProperties(); } } catch { // I don't know if we can/should try to log this. I'm going to guess that we don't want to // and can't safely call any LoggingService.Log methods anyway in case we'd recurse, though // the 'reporting' boolean should take care of that. } finally { reporting = false; } }
public static void Shutdown() { if (!initialized) { return; } if (ShuttingDown != null) { ShuttingDown(null, EventArgs.Empty); } PropertyService.SaveProperties(); if (processService != null) { processService.Dispose(); processService = null; } initialized = false; }
internal static void ReportUnhandledException(Exception ex, bool willShutDown, bool silently, string tag) { var tags = new List <string> { tag }; if (reporting) { return; } reporting = true; try { var oldReportCrashes = ReportCrashes; if (UnhandledErrorOccured != null && !silently) { ReportCrashes = UnhandledErrorOccured(ReportCrashes, ex, willShutDown); } // If crash reporting has been explicitly disabled, disregard this crash if (ReportCrashes.HasValue && !ReportCrashes.Value) { return; } byte[] data; using (var stream = new MemoryStream()) { using (var writer = System.Xml.XmlWriter.Create(stream)) { writer.WriteStartElement("CrashLog"); writer.WriteAttributeString("version", ServiceVersion); writer.WriteElementString("SystemInformation", SystemInformation.GetTextDescription()); writer.WriteElementString("Exception", ex.ToString()); writer.WriteEndElement(); } data = stream.ToArray(); } var customData = new Hashtable(); customData["SystemInformation"] = SystemInformation.GetTextDescription(); if (raygunClient != null) { ThreadPool.QueueUserWorkItem(delegate { raygunClient.Send(ex, tags, customData, BuildInfo.Version); }); } // Log to disk only if uploading fails. var filename = string.Format("{0}.{1}.{2}.crashlog", DateTime.UtcNow.ToString("yyyy-MM-dd__HH-mm-ss"), SystemInformation.SessionUuid, Interlocked.Increment(ref CrashId)); ThreadPool.QueueUserWorkItem(delegate { if (!TryUploadReport(filename, data)) { if (!Directory.Exists(CrashLogDirectory)) { Directory.CreateDirectory(CrashLogDirectory); } File.WriteAllBytes(CrashLogDirectory.Combine(filename), data); } }); //ensure we don't lose the setting if (ReportCrashes != oldReportCrashes) { PropertyService.SaveProperties(); } } finally { reporting = false; } }