diff --git a/src/NzbDrone.Mono/EnvironmentInfo/MonoPlatformInfo.cs b/src/NzbDrone.Mono/EnvironmentInfo/MonoPlatformInfo.cs index 8fe776f07..e883cea94 100644 --- a/src/NzbDrone.Mono/EnvironmentInfo/MonoPlatformInfo.cs +++ b/src/NzbDrone.Mono/EnvironmentInfo/MonoPlatformInfo.cs @@ -37,7 +37,7 @@ namespace NzbDrone.Mono.EnvironmentInfo } catch (Exception ex) { - logger.Error(ex, "Unable to get mono version: " + ex.Message); + logger.Error(ex, "Unable to get mono version"); } Version = runTimeVersion; diff --git a/src/NzbDrone.Windows/EnvironmentInfo/DotNetPlatformInfo.cs b/src/NzbDrone.Windows/EnvironmentInfo/DotNetPlatformInfo.cs index f5cf9c583..015b1270c 100644 --- a/src/NzbDrone.Windows/EnvironmentInfo/DotNetPlatformInfo.cs +++ b/src/NzbDrone.Windows/EnvironmentInfo/DotNetPlatformInfo.cs @@ -1,13 +1,17 @@ using System; using Microsoft.Win32; +using NLog; using NzbDrone.Common.EnvironmentInfo; namespace NzbDrone.Windows.EnvironmentInfo { public class DotNetPlatformInfo : PlatformInfo { - public DotNetPlatformInfo() + private readonly Logger _logger; + + public DotNetPlatformInfo(Logger logger) { + _logger = logger; var version = GetFrameworkVersion(); Environment.SetEnvironmentVariable("RUNTIME_VERSION", version.ToString()); Version = version; @@ -15,45 +19,52 @@ namespace NzbDrone.Windows.EnvironmentInfo public override Version Version { get; } - private static Version GetFrameworkVersion() + private Version GetFrameworkVersion() { - const string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\"; - using (var ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(subkey)) + try { - if (ndpKey == null) + const string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\"; + using (var ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(subkey)) { - return new Version(4, 0); - } + if (ndpKey == null) + { + return new Version(4, 0); + } - var releaseKey = (int)ndpKey.GetValue("Release"); + var releaseKey = (int)ndpKey.GetValue("Release"); - if (releaseKey >= 394802) - { - return new Version(4, 6, 2); - } - if (releaseKey >= 394254) - { - return new Version(4, 6, 1); - } - if (releaseKey >= 393295) - { - return new Version(4, 6); - } - if (releaseKey >= 379893) - { - return new Version(4, 5, 2); + if (releaseKey >= 394802) + { + return new Version(4, 6, 2); + } + if (releaseKey >= 394254) + { + return new Version(4, 6, 1); + } + if (releaseKey >= 393295) + { + return new Version(4, 6); + } + if (releaseKey >= 379893) + { + return new Version(4, 5, 2); + } + if (releaseKey >= 378675) + { + return new Version(4, 5, 1); + } + if (releaseKey >= 378389) + { + return new Version(4, 5); + } } - if (releaseKey >= 378675) - { - return new Version(4, 5, 1); - } - if (releaseKey >= 378389) - { - return new Version(4, 5); - } - - return new Version(4, 0); } + catch (Exception e) + { + _logger.Error(e, "Couldnt get .NET framework version"); + } + + return new Version(4, 0); } } }