diff --git a/Wabbajack.Common/ExtensionManager.cs b/Wabbajack.Common/ExtensionManager.cs index 34651409..1f0f5075 100644 --- a/Wabbajack.Common/ExtensionManager.cs +++ b/Wabbajack.Common/ExtensionManager.cs @@ -33,25 +33,26 @@ namespace Wabbajack.Common var progIDKey = Registry.CurrentUser.OpenSubKey(ProgIDPath); var tempKey = progIDKey?.OpenSubKey("shell\\open\\command"); if (progIDKey == null || tempKey == null) return true; - return tempKey.GetValue("").ToString().Equals($"\"{appPath}\" -i \"%1\""); + var value = tempKey.GetValue(""); + return value == null || value.ToString().Equals($"\"{appPath}\" -i \"%1\""); } public static bool IsAssociated() { var progIDKey = Registry.CurrentUser.OpenSubKey(ProgIDPath); var extKey = Registry.CurrentUser.OpenSubKey(ExtPath); - return (progIDKey != null && extKey != null); + return progIDKey != null && extKey != null; } public static void Associate(string appPath) { var progIDKey = Registry.CurrentUser.CreateSubKey(ProgIDPath, RegistryKeyPermissionCheck.ReadWriteSubTree); - foreach (KeyValuePair entry in ProgIDList) + foreach (var entry in ProgIDList) { if (entry.Key.Contains("\\")) { - var tempKey = progIDKey.CreateSubKey(entry.Key); - tempKey.SetValue("", entry.Value.Replace("{appPath}", appPath)); + var tempKey = progIDKey?.CreateSubKey(entry.Key); + tempKey?.SetValue("", entry.Value.Replace("{appPath}", appPath)); } else { @@ -60,7 +61,7 @@ namespace Wabbajack.Common } var extKey = Registry.CurrentUser.CreateSubKey(ExtPath, RegistryKeyPermissionCheck.ReadWriteSubTree); - foreach (KeyValuePair entry in ExtList) + foreach (var entry in ExtList) { extKey?.SetValue(entry.Key, entry.Value); } diff --git a/Wabbajack/Views/MainWindow.xaml.cs b/Wabbajack/Views/MainWindow.xaml.cs index bf7cbe01..9c9139aa 100644 --- a/Wabbajack/Views/MainWindow.xaml.cs +++ b/Wabbajack/Views/MainWindow.xaml.cs @@ -4,6 +4,7 @@ using System.Windows; using MahApps.Metro.Controls; using Wabbajack.Common; using Application = System.Windows.Application; +using Utils = Wabbajack.Common.Utils; namespace Wabbajack { @@ -25,10 +26,18 @@ namespace Wabbajack }; var appPath = System.Reflection.Assembly.GetExecutingAssembly().Location; - if (!ExtensionManager.IsAssociated() || ExtensionManager.NeedsUpdating(appPath)) + try { - ExtensionManager.Associate(appPath); + if (!ExtensionManager.IsAssociated() || ExtensionManager.NeedsUpdating(appPath)) + { + ExtensionManager.Associate(appPath); + } } + catch (Exception e) + { + Utils.Log($"ExtensionManager had an exception:\n{e}"); + } + Wabbajack.Common.Utils.Log($"Wabbajack Build - {ThisAssembly.Git.Sha}");