From ab0ef80819a6d509705ae2c3867f3437a28d5e9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20H=C3=B6glinger-Stelzer?= Date: Thu, 25 Oct 2018 13:20:52 +0200 Subject: [PATCH] Added .NET version check Added error handler --- DerpingDrivers/App.config | 12 +++++-- DerpingDrivers/App.xaml.cs | 47 ++++++++++++++++++++++------ DerpingDrivers/DerpingDrivers.csproj | 18 +++++++++++ DerpingDrivers/app.manifest | 2 -- DerpingDrivers/packages.config | 4 +++ 5 files changed, 70 insertions(+), 13 deletions(-) diff --git a/DerpingDrivers/App.config b/DerpingDrivers/App.config index bae5d6d..61e8d77 100644 --- a/DerpingDrivers/App.config +++ b/DerpingDrivers/App.config @@ -1,6 +1,14 @@ - + - + + + + + + + + + diff --git a/DerpingDrivers/App.xaml.cs b/DerpingDrivers/App.xaml.cs index 3fc5bb4..9fb2a02 100644 --- a/DerpingDrivers/App.xaml.cs +++ b/DerpingDrivers/App.xaml.cs @@ -1,17 +1,46 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; -using System.Linq; -using System.Threading.Tasks; -using System.Windows; +using System.Windows; +using ExceptionReporting; +using Microsoft.Win32; namespace DerpingDrivers { /// - /// Interaction logic for App.xaml + /// Interaction logic for App.xaml /// public partial class App : Application { + public App() + { + var netRelease = (int) Registry.GetValue( + @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full", + "Release", + 0); + + // This is a big ugly but catches cases where invoked without the app.config + if (netRelease < 394254) + { + MessageBox.Show( + "This program requires the .NET Framework v4.6.1 (or higher) to run properly, please install!", + "Missing .NET", MessageBoxButton.OK, MessageBoxImage.Error); + Shutdown(-1); + return; + } + + DispatcherUnhandledException += (sender, args) => + { + var er = new ExceptionReporter + { + Config = + { + AppName = "DerpingDrivers", + SendMethod = ReportSendMethod.None + } + }; + er.Show(args.Exception); + + args.Handled = true; + Shutdown(-2); + }; + } } -} +} \ No newline at end of file diff --git a/DerpingDrivers/DerpingDrivers.csproj b/DerpingDrivers/DerpingDrivers.csproj index 5c101d4..2602204 100644 --- a/DerpingDrivers/DerpingDrivers.csproj +++ b/DerpingDrivers/DerpingDrivers.csproj @@ -52,6 +52,15 @@ ..\packages\Costura.Fody.3.1.6\lib\net46\Costura.dll + + ..\packages\DotNetZip.1.11.0\lib\net20\DotNetZip.dll + + + ..\packages\ExceptionReporter.4.0.2\lib\net40\ExceptionReporter.NET.dll + + + ..\packages\Handlebars.Net.1.9.5\lib\net452\Handlebars.dll + ..\packages\MahApps.Metro.1.6.5\lib\net46\MahApps.Metro.dll @@ -70,8 +79,17 @@ ..\packages\PInvoke.Windows.Core.0.5.155\lib\net35\PInvoke.Windows.Core.dll + + ..\packages\Simple-MAPI.NET.1.1.0\lib\net20\SimpleMapi.dll + + + + + + + ..\packages\ControlzEx.3.0.2.4\lib\net45\System.Windows.Interactivity.dll diff --git a/DerpingDrivers/app.manifest b/DerpingDrivers/app.manifest index f6dce57..ba89d22 100644 --- a/DerpingDrivers/app.manifest +++ b/DerpingDrivers/app.manifest @@ -58,7 +58,6 @@ --> - diff --git a/DerpingDrivers/packages.config b/DerpingDrivers/packages.config index ca56246..5901955 100644 --- a/DerpingDrivers/packages.config +++ b/DerpingDrivers/packages.config @@ -2,11 +2,15 @@ + + + + \ No newline at end of file