mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-08-29 13:28:04 +00:00
Added a check to verify that at least .NET Framework 4.5 is installed.
This commit is contained in:
parent
2b9ec17583
commit
566ab46c0a
26
Program.cs
26
Program.cs
@ -4,12 +4,14 @@
|
|||||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
Copyright (C) 2009-2013 Michael Möller <mmoeller@openhardwaremonitor.org>
|
Copyright (C) 2009-2020 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using OpenHardwareMonitor.GUI;
|
using OpenHardwareMonitor.GUI;
|
||||||
@ -29,7 +31,7 @@ namespace OpenHardwareMonitor {
|
|||||||
new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
|
new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!AllRequiredFilesAvailable())
|
if (!AllRequiredFilesAvailable() || !IsNetFramework45Installed())
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
|
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
@ -68,6 +70,26 @@ namespace OpenHardwareMonitor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool IsNetFramework45Installed() {
|
||||||
|
Type type;
|
||||||
|
try {
|
||||||
|
type = TryGetDefaultDllImportSearchPathsAttributeType();
|
||||||
|
} catch (TypeLoadException) {
|
||||||
|
MessageBox.Show(
|
||||||
|
"This application requires the .NET Framework 4.5 or a later version.\n" +
|
||||||
|
"Please install the latest .NET Framework. For more information, see\n\n" +
|
||||||
|
"https://dotnet.microsoft.com/download/dotnet-framework",
|
||||||
|
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return type != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
|
private static Type TryGetDefaultDllImportSearchPathsAttributeType() {
|
||||||
|
return typeof(DefaultDllImportSearchPathsAttribute);
|
||||||
|
}
|
||||||
|
|
||||||
private static void ReportException(Exception e) {
|
private static void ReportException(Exception e) {
|
||||||
CrashForm form = new CrashForm();
|
CrashForm form = new CrashForm();
|
||||||
form.Exception = e;
|
form.Exception = e;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user