Skip to content

Commit 5b9b984

Browse files
committed
Fixed issue where crash report from Windows 8.1 and Windows 10 was reported as coming from Windows 8 in DoctorDump crash report.
1 parent a6fe6a4 commit 5b9b984

8 files changed

Lines changed: 63 additions & 96 deletions

File tree

CrashReporter.NET.sln

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,32 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 14
4-
VisualStudioVersion = 14.0.23107.0
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26403.7
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrashReporter.NET", "CrashReporter.NET\CrashReporter.NET.csproj", "{67912BDA-1572-46B0-8623-5872D9DADBC8}"
77
EndProject
88
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrashReporterTest", "CrashReporterTest\CrashReporterTest.csproj", "{895AE503-6920-4BFF-9D47-3A91F90E8606}"
99
EndProject
1010
Global
11-
GlobalSection(SubversionScc) = preSolution
12-
Svn-Managed = True
13-
Manager = AnkhSVN - Subversion Support for Visual Studio
14-
EndGlobalSection
1511
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1612
Debug|Any CPU = Debug|Any CPU
17-
Debug|Mixed Platforms = Debug|Mixed Platforms
18-
Debug|x86 = Debug|x86
1913
Release|Any CPU = Release|Any CPU
20-
Release|Mixed Platforms = Release|Mixed Platforms
21-
Release|x86 = Release|x86
2214
EndGlobalSection
2315
GlobalSection(ProjectConfigurationPlatforms) = postSolution
2416
{67912BDA-1572-46B0-8623-5872D9DADBC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2517
{67912BDA-1572-46B0-8623-5872D9DADBC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
26-
{67912BDA-1572-46B0-8623-5872D9DADBC8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
27-
{67912BDA-1572-46B0-8623-5872D9DADBC8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
28-
{67912BDA-1572-46B0-8623-5872D9DADBC8}.Debug|x86.ActiveCfg = Debug|Any CPU
2918
{67912BDA-1572-46B0-8623-5872D9DADBC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
3019
{67912BDA-1572-46B0-8623-5872D9DADBC8}.Release|Any CPU.Build.0 = Release|Any CPU
31-
{67912BDA-1572-46B0-8623-5872D9DADBC8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
32-
{67912BDA-1572-46B0-8623-5872D9DADBC8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
33-
{67912BDA-1572-46B0-8623-5872D9DADBC8}.Release|x86.ActiveCfg = Release|Any CPU
3420
{895AE503-6920-4BFF-9D47-3A91F90E8606}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
3521
{895AE503-6920-4BFF-9D47-3A91F90E8606}.Debug|Any CPU.Build.0 = Debug|Any CPU
36-
{895AE503-6920-4BFF-9D47-3A91F90E8606}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
37-
{895AE503-6920-4BFF-9D47-3A91F90E8606}.Debug|Mixed Platforms.Build.0 = Debug|x86
38-
{895AE503-6920-4BFF-9D47-3A91F90E8606}.Debug|x86.ActiveCfg = Debug|x86
39-
{895AE503-6920-4BFF-9D47-3A91F90E8606}.Debug|x86.Build.0 = Debug|x86
4022
{895AE503-6920-4BFF-9D47-3A91F90E8606}.Release|Any CPU.ActiveCfg = Release|Any CPU
4123
{895AE503-6920-4BFF-9D47-3A91F90E8606}.Release|Any CPU.Build.0 = Release|Any CPU
42-
{895AE503-6920-4BFF-9D47-3A91F90E8606}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
43-
{895AE503-6920-4BFF-9D47-3A91F90E8606}.Release|Mixed Platforms.Build.0 = Release|Any CPU
44-
{895AE503-6920-4BFF-9D47-3A91F90E8606}.Release|x86.ActiveCfg = Release|x86
45-
{895AE503-6920-4BFF-9D47-3A91F90E8606}.Release|x86.Build.0 = Release|x86
4624
EndGlobalSection
4725
GlobalSection(SolutionProperties) = preSolution
4826
HideSolutionNode = FALSE
4927
EndGlobalSection
28+
GlobalSection(SubversionScc) = preSolution
29+
Svn-Managed = True
30+
Manager = AnkhSVN - Subversion Support for Visual Studio
31+
EndGlobalSection
5032
EndGlobal

CrashReporter.NET/CrashReport.cs

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public CrashReport(ReportCrash reportCrashObject)
4444
SendAnonymousReport();
4545
}
4646

47-
public override sealed string Text
47+
public sealed override string Text
4848
{
4949
get { return base.Text; }
5050
set { base.Text = value; }
@@ -59,8 +59,7 @@ private void CrashReportLoad(object sender, EventArgs e)
5959
textBoxMessage.Text = _reportCrash.Exception.Message;
6060
textBoxTime.Text = DateTime.Now.ToString(CultureInfo.InvariantCulture);
6161
textBoxSource.Text = _reportCrash.Exception.Source;
62-
textBoxStackTrace.Text = string.Format("{0}\n{1}", _reportCrash.Exception.InnerException,
63-
_reportCrash.Exception.StackTrace);
62+
textBoxStackTrace.Text = $@"{_reportCrash.Exception.InnerException}\n{_reportCrash.Exception.StackTrace}";
6463
}
6564

6665
private void CrashReport_Shown(object sender, EventArgs e)
@@ -93,9 +92,9 @@ private void ButtonSendReportClick(object sender, EventArgs e)
9392
var fromAddress = !string.IsNullOrEmpty(_reportCrash.FromEmail) ? new MailAddress(_reportCrash.FromEmail) : null;
9493
var toAddress = new MailAddress(_reportCrash.ToEmail);
9594

96-
const string r0_255 = @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])";
95+
const string r0To255 = @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])";
9796
var regexEmail = new Regex(@"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@"
98-
+ @"((" + r0_255 + @"\." + r0_255 + @"\." + r0_255 + @"\." + r0_255 + @"){1}|"
97+
+ @"((" + r0To255 + @"\." + r0To255 + @"\." + r0To255 + @"\." + r0To255 + @"){1}|"
9998
+ @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$");
10099
var subject = "";
101100

@@ -122,14 +121,13 @@ private void ButtonSendReportClick(object sender, EventArgs e)
122121
{
123122
errorProviderEmail.SetError(textBoxEmail, "");
124123
fromAddress = new MailAddress(textBoxEmail.Text.Trim());
125-
subject = string.Format("{0} {1} Crash Report by {2}", _reportCrash.ApplicationTitle,
126-
_reportCrash.ApplicationVersion, textBoxEmail.Text.Trim());
124+
subject =
125+
$"{_reportCrash.ApplicationTitle} {_reportCrash.ApplicationVersion} Crash Report by {textBoxEmail.Text.Trim()}";
127126
}
128127
}
129128
if (string.IsNullOrEmpty(subject.Trim()))
130129
{
131-
subject = string.Format("{0} {1} Crash Report", _reportCrash.ApplicationTitle,
132-
_reportCrash.ApplicationVersion);
130+
subject = $"{_reportCrash.ApplicationTitle} {_reportCrash.ApplicationVersion} Crash Report";
133131
}
134132

135133
if (_reportCrash.AnalyzeWithDoctorDump)
@@ -282,81 +280,80 @@ private string HtmlReport()
282280
CreateReport(_reportCrash.Exception));
283281
if (!String.IsNullOrEmpty(textBoxUserMessage.Text.Trim()))
284282
{
285-
report += string.Format(@"<br/>
283+
report += $@"<br/>
286284
<div class=""content"">
287285
<div class=""title"" style=""background-color: #66FF99;"">
288286
<h3>User Comment</h3>
289287
</div>
290288
<div class=""message"">
291-
<p>{0}</p>
289+
<p>{HttpUtility.HtmlEncode(textBoxUserMessage.Text.Trim())}</p>
292290
</div>
293-
</div>", HttpUtility.HtmlEncode(textBoxUserMessage.Text.Trim()));
291+
</div>";
294292
}
295293
if (!String.IsNullOrEmpty(_reportCrash.DeveloperMessage.Trim()))
296294
{
297-
report += string.Format(@"<br/>
295+
report += $@"<br/>
298296
<div class=""content"">
299297
<div class=""title"" style=""background-color: #66FF99;"">
300298
<h3>Developer Message</h3>
301299
</div>
302300
<div class=""message"">
303-
<p>{0}</p>
301+
<p>{HttpUtility.HtmlEncode(_reportCrash.DeveloperMessage.Trim())}</p>
304302
</div>
305-
</div>", HttpUtility.HtmlEncode(_reportCrash.DeveloperMessage.Trim()));
303+
</div>";
306304
}
307305
report += "</body></html>";
308306
return report;
309307
}
310308

311309
private string CreateReport(Exception exception)
312310
{
313-
string report = string.Format(@"<br/>
311+
string report = $@"<br/>
314312
<div class=""content"">
315313
<div class=""title"" style=""background-color: #66CCFF;"">
316314
<h3>Exception Type</h3>
317315
</div>
318316
<div class=""message"">
319-
<p>{0}</p>
317+
<p>{HttpUtility.HtmlEncode(exception.GetType().ToString())}</p>
320318
</div>
321319
</div><br/>
322320
<div class=""content"">
323321
<div class=""title"" style=""background-color: #66CCFF;"">
324322
<h3>Error Message</h3>
325323
</div>
326324
<div class=""message"">
327-
<p>{1}</p>
325+
<p>{HttpUtility.HtmlEncode(exception.Message)}</p>
328326
</div>
329327
</div><br/>
330328
<div class=""content"">
331329
<div class=""title"" style=""background-color: #66CCFF;"">
332330
<h3>Source</h3>
333331
</div>
334332
<div class=""message"">
335-
<p>{2}</p>
333+
<p>{HttpUtility.HtmlEncode(exception.Source ?? "No source")}</p>
336334
</div>
337335
</div><br/>
338336
<div class=""content"">
339337
<div class=""title"" style=""background-color: #66CCFF;"">
340338
<h3>Stack Trace</h3>
341339
</div>
342340
<div class=""message"">
343-
<p>{3}</p>
341+
<p>{
342+
HttpUtility.HtmlEncode(exception.StackTrace ?? "No stack trace").Replace("\r\n", "<br/>")
343+
}</p>
344344
</div>
345-
</div>", HttpUtility.HtmlEncode(exception.GetType().ToString()),
346-
HttpUtility.HtmlEncode(exception.Message),
347-
HttpUtility.HtmlEncode(exception.Source ?? "No source"),
348-
HttpUtility.HtmlEncode(exception.StackTrace ?? "No stack trace").Replace("\r\n", "<br/>"));
345+
</div>";
349346
if (exception.InnerException != null)
350347
{
351-
report += string.Format(@"<br/>
348+
report += $@"<br/>
352349
<div class=""content"">
353350
<div class=""title"" style=""background-color: #66CCFF;"">
354351
<h3>Inner Exception</h3>
355352
</div>
356353
<div class=""message"">
357-
{0}
354+
{CreateReport(exception.InnerException)}
358355
</div>
359-
</div>", CreateReport(exception.InnerException));
356+
</div>";
360357
}
361358
report += "<br/>";
362359
return report;

CrashReporter.NET/DrDump/SendRequestState.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal class SendRequestState
1313

1414
public SendAnonymousReportCompletedEventArgs SendAnonymousReportResult { get; set; }
1515

16-
static private ExceptionInfo ConvertToExceptionInfo(Exception e, bool anonymous)
16+
private static ExceptionInfo ConvertToExceptionInfo(Exception e, bool anonymous)
1717
{
1818
if (e == null)
1919
return null;
@@ -28,7 +28,7 @@ static private ExceptionInfo ConvertToExceptionInfo(Exception e, bool anonymous)
2828
};
2929
}
3030

31-
static private System.Net.NetworkInformation.PhysicalAddress GetMacAddress()
31+
private static System.Net.NetworkInformation.PhysicalAddress GetMacAddress()
3232
{
3333
var googleDns = new System.Net.Sockets.UdpClient("8.8.8.8", 53);
3434
IPAddress localAddress = ((IPEndPoint)googleDns.Client.LocalEndPoint).Address;
@@ -62,6 +62,8 @@ internal DetailedExceptionDescription GetDetailedExceptionDescription()
6262
};
6363
}
6464

65+
66+
6567
internal ExceptionDescription GetExceptionDescription(bool anonymous)
6668
{
6769
var oldCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
@@ -70,7 +72,7 @@ internal ExceptionDescription GetExceptionDescription(bool anonymous)
7072
System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
7173

7274
var osVersion = Environment.OSVersion;
73-
var os = string.Format("os={0};v={1};spname={2}", osVersion.Platform, osVersion.Version, osVersion.ServicePack);
75+
var os = $"os={osVersion.Platform};v={HelperMethods.GetOSVersion()};spname={osVersion.ServicePack}";
7476

7577
var exceptionDescription = new ExceptionDescription
7678
{
@@ -104,7 +106,7 @@ internal Application GetApplication()
104106

105107
return new Application
106108
{
107-
ApplicationGUID = AnonymousData.ApplicationID.HasValue ? AnonymousData.ApplicationID.Value.ToString("D") : null,
109+
ApplicationGUID = AnonymousData.ApplicationID?.ToString("D"),
108110
AppName = appTitle,
109111
CompanyName = appCompany,
110112
Email = AnonymousData.ToEmail,
@@ -116,7 +118,7 @@ internal Application GetApplication()
116118
};
117119
}
118120

119-
static internal ClientLib GetClientLib()
121+
internal static ClientLib GetClientLib()
120122
{
121123
var clientVersion = typeof(CrashReport).Assembly.GetName().Version;
122124
return new ClientLib

CrashReporter.NET/HelperMethods.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,17 @@ private static string HKLM_GetString(string key, string value)
6363
{
6464
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(key);
6565
if (registryKey == null) return "";
66-
return (string)registryKey.GetValue(value);
66+
return registryKey.GetValue(value).ToString();
6767
}
68-
catch { return ""; }
68+
catch
69+
{
70+
return "";
71+
}
72+
}
73+
74+
public static string GetOSVersion()
75+
{
76+
return $"{HKLM_GetString(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentMajorVersionNumber")}.{HKLM_GetString(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentMinorVersionNumber")}.{HKLM_GetString(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentBuildNumber")}.0";
6977
}
7078

7179
private delegate bool IsWow64ProcessDelegate([In] IntPtr handle, [Out] out bool isWow64Process);
@@ -86,7 +94,8 @@ public static string GetWindowsVersion()
8694
string currentBuild = HKLM_GetString(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentBuild");
8795
if (productName != "")
8896
{
89-
return string.Format("{0}{1}{2}{3} (OS Build {4})", (productName.StartsWith("Microsoft") ? "" : "Microsoft "), productName, (csdVersion != "" ? " " + csdVersion : ""), osArchitecture, currentBuild);
97+
return
98+
$"{(productName.StartsWith("Microsoft") ? "" : "Microsoft ")}{productName}{(csdVersion != "" ? " " + csdVersion : "")} {osArchitecture} (OS Build {currentBuild})";
9099
}
91100
return "";
92101
}

CrashReporter.NET/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
[assembly: AssemblyConfiguration("")]
1212
[assembly: AssemblyCompany("RBSoft")]
1313
[assembly: AssemblyProduct("CrashReporter.NET")]
14-
[assembly: AssemblyCopyright("Copyright © 2012-2016 RBSoft")]
14+
[assembly: AssemblyCopyright("Copyright © 2012-2017 RBSoft")]
1515
[assembly: AssemblyTrademark("")]
1616
[assembly: AssemblyCulture("")]
1717

@@ -36,6 +36,6 @@
3636
// by using the '*' as shown below:
3737
// [assembly: AssemblyVersion("1.0.*")]
3838

39-
[assembly: AssemblyVersion("1.5.1.0")]
40-
[assembly: AssemblyFileVersion("1.5.1.0")]
39+
[assembly: AssemblyVersion("1.5.2.0")]
40+
[assembly: AssemblyFileVersion("1.5.2.0")]
4141
[assembly: NeutralResourcesLanguageAttribute("en")]

CrashReporter.NET/ReportCrash.cs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public class ReportCrash
7777
/// Gets or Sets the current culture to use by the library.
7878
/// </summary>
7979
public CultureInfo CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
80-
80+
8181
/// <summary>
8282
/// Specify whether CrashReporter.NET should send crash reports only for new problems (duplicates detected by Doctor Dump free cloud service).
8383
/// </summary>
@@ -125,8 +125,7 @@ public void Send(Exception exception)
125125

126126
try
127127
{
128-
ScreenShot = string.Format(@"{0}\{1} Crash Screenshot.png", Path.GetTempPath(),
129-
ApplicationTitle);
128+
ScreenShot = $@"{Path.GetTempPath()}\{ApplicationTitle} Crash Screenshot.png";
130129
if (CaptureScreen)
131130
CaptureScreenshot.CaptureScreen(ScreenShot, ImageFormat.Png);
132131
else
@@ -139,19 +138,16 @@ public void Send(Exception exception)
139138
if (String.IsNullOrEmpty(ToEmail) || !AnalyzeWithDoctorDump && (String.IsNullOrEmpty(FromEmail) || String.IsNullOrEmpty(SmtpHost)))
140139
return;
141140

142-
var parameterizedThreadStart = new ParameterizedThreadStart(ShowUI);
143-
var thread = new Thread(parameterizedThreadStart) {IsBackground = false};
144-
thread.CurrentCulture = thread.CurrentUICulture = CurrentCulture ?? System.Windows.Forms.Application.CurrentCulture;
141+
var parameterizedThreadStart = new ParameterizedThreadStart(delegate
142+
{
143+
new CrashReport(this).ShowDialog();
144+
});
145+
var thread = new Thread(parameterizedThreadStart) { IsBackground = false };
146+
thread.CurrentCulture = thread.CurrentUICulture = CurrentCulture ?? Thread.CurrentThread.CurrentCulture;
145147
thread.SetApartmentState(ApartmentState.STA);
146148
thread.Start(this);
147149
thread.Join();
148150
}
149-
150-
private static void ShowUI(object reportCrash)
151-
{
152-
var crashReport = new CrashReport((ReportCrash) reportCrash);
153-
crashReport.ShowDialog();
154-
}
155151
}
156152

157153
/// <summary>

CrashReporterTest/CrashReporterTest.csproj

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,6 @@
1313
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
1414
<FileAlignment>512</FileAlignment>
1515
</PropertyGroup>
16-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
17-
<PlatformTarget>x86</PlatformTarget>
18-
<DebugSymbols>true</DebugSymbols>
19-
<DebugType>full</DebugType>
20-
<Optimize>false</Optimize>
21-
<OutputPath>bin\Debug\</OutputPath>
22-
<DefineConstants>DEBUG;TRACE</DefineConstants>
23-
<ErrorReport>prompt</ErrorReport>
24-
<WarningLevel>4</WarningLevel>
25-
</PropertyGroup>
26-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
27-
<PlatformTarget>x86</PlatformTarget>
28-
<DebugType>pdbonly</DebugType>
29-
<Optimize>true</Optimize>
30-
<OutputPath>bin\Release\</OutputPath>
31-
<DefineConstants>TRACE</DefineConstants>
32-
<ErrorReport>prompt</ErrorReport>
33-
<WarningLevel>4</WarningLevel>
34-
</PropertyGroup>
3516
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
3617
<DebugSymbols>true</DebugSymbols>
3718
<OutputPath>bin\Debug\</OutputPath>

CrashReporterTest/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[assembly: AssemblyConfiguration("")]
1010
[assembly: AssemblyCompany("RBSoft")]
1111
[assembly: AssemblyProduct("CrashReporterTest")]
12-
[assembly: AssemblyCopyright("Copyright © 2012-2016 RBSoft")]
12+
[assembly: AssemblyCopyright("Copyright © 2012-2017 RBSoft")]
1313
[assembly: AssemblyTrademark("")]
1414
[assembly: AssemblyCulture("")]
1515

@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.5.1.0")]
35-
[assembly: AssemblyFileVersion("1.5.1.0")]
34+
[assembly: AssemblyVersion("1.5.2.0")]
35+
[assembly: AssemblyFileVersion("1.5.2.0")]

0 commit comments

Comments
 (0)