64
64
ReportUnhandledException (ex, willShutDown, false);
67
static bool reporting;
67
69
public static void ReportUnhandledException (Exception ex, bool willShutDown, bool silently)
69
var oldReportCrashes = ReportCrashes;
71
if (UnhandledErrorOccured != null && !silently)
72
ReportCrashes = UnhandledErrorOccured (ReportCrashes, ex, willShutDown);
74
// If crash reporting has been explicitly disabled, disregard this crash
75
if (ReportCrashes.HasValue && !ReportCrashes.Value)
79
using (var stream = new MemoryStream ()) {
80
using (var writer = System.Xml.XmlWriter.Create (stream)) {
81
writer.WriteStartElement ("CrashLog");
82
writer.WriteAttributeString ("version", ServiceVersion);
84
writer.WriteElementString ("SystemInformation", SystemInformation.ToText ());
85
writer.WriteElementString ("Exception", ex.ToString ());
87
writer.WriteEndElement ();
76
var oldReportCrashes = ReportCrashes;
78
if (UnhandledErrorOccured != null && !silently)
79
ReportCrashes = UnhandledErrorOccured (ReportCrashes, ex, willShutDown);
81
// If crash reporting has been explicitly disabled, disregard this crash
82
if (ReportCrashes.HasValue && !ReportCrashes.Value)
86
using (var stream = new MemoryStream ()) {
87
using (var writer = System.Xml.XmlWriter.Create (stream)) {
88
writer.WriteStartElement ("CrashLog");
89
writer.WriteAttributeString ("version", ServiceVersion);
91
writer.WriteElementString ("SystemInformation", SystemInformation.GetTextDescription ());
92
writer.WriteElementString ("Exception", ex.ToString ());
94
writer.WriteEndElement ();
96
data = stream.ToArray ();
99
// Log to disk only if uploading fails.
100
var filename = string.Format ("{0}.{1}.{2}.crashlog", DateTime.UtcNow.ToString ("yyyy-MM-dd__HH-mm-ss"), SystemInformation.SessionUuid, Interlocked.Increment (ref CrashId));
101
ThreadPool.QueueUserWorkItem (delegate {
102
if (!TryUploadReport (filename, data)) {
103
if (!Directory.Exists (CrashLogDirectory))
104
Directory.CreateDirectory (CrashLogDirectory);
106
File.WriteAllBytes (CrashLogDirectory.Combine (filename), data);
89
data = stream.ToArray ();
92
// Log to disk only if uploading fails.
93
var filename = string.Format ("{0}.{1}.{2}.crashlog", DateTime.UtcNow.ToString ("yyyy-MM-dd__HH-mm-ss"), SystemInformation.SessionUuid, Interlocked.Increment (ref CrashId));
94
ThreadPool.QueueUserWorkItem (delegate {
95
if (!TryUploadReport (filename, data)) {
96
if (!Directory.Exists (CrashLogDirectory))
97
Directory.CreateDirectory (CrashLogDirectory);
110
//ensure we don't lose the setting
111
if (ReportCrashes != oldReportCrashes) {
112
PropertyService.SaveProperties ();
99
File.WriteAllBytes (CrashLogDirectory.Combine (filename), data);
103
//ensure we don't lose the setting
104
if (ReportCrashes != oldReportCrashes) {
105
PropertyService.SaveProperties ();