diff --git a/SophiApp/SophiApp/Helpers/RegHelper.cs b/SophiApp/SophiApp/Helpers/RegHelper.cs index 9092483f..46399bec 100644 --- a/SophiApp/SophiApp/Helpers/RegHelper.cs +++ b/SophiApp/SophiApp/Helpers/RegHelper.cs @@ -6,7 +6,7 @@ namespace SophiApp.Helpers { internal class RegHelper { - private static RegistryKey GetKey(RegistryHive hive, string keyPath) => RegistryKey.OpenBaseKey(hive, RegistryView.Registry64).OpenSubKey(keyPath); + private static RegistryKey GetKey(RegistryHive hive, string keyPath) => RegistryKey.OpenBaseKey(hive, RegistryView.Registry64)?.OpenSubKey(keyPath); private static RegistryKey SetKey(RegistryHive hive, string keyPath) => RegistryKey.OpenBaseKey(hive, RegistryView.Registry64).OpenSubKey(keyPath, true) ?? RegistryKey.OpenBaseKey(hive, RegistryView.Registry64).CreateSubKey(keyPath, true); diff --git a/SophiApp/SophiApp/Helpers/VisualRedistrLibsHelper.cs b/SophiApp/SophiApp/Helpers/VisualRedistrLibsHelper.cs index 1abc8200..d791f108 100644 --- a/SophiApp/SophiApp/Helpers/VisualRedistrLibsHelper.cs +++ b/SophiApp/SophiApp/Helpers/VisualRedistrLibsHelper.cs @@ -33,11 +33,18 @@ internal static Version GetInstalledVersion() internal static bool IsInstalled() { - var vcRegistryPath = RegHelper.GetSubKeyNames(RegistryHive.ClassesRoot, REDISTRX64_REGISTRY_PATH) + try + { + var vcRegistryPath = RegHelper.GetSubKeyNames(RegistryHive.ClassesRoot, REDISTRX64_REGISTRY_PATH) .FirstOrDefault(key => key.Contains(REDISTRX64_REGISTRY_NAME_PATTERN)); - return vcRegistryPath != null && RegHelper.GetStringValue(RegistryHive.ClassesRoot, vcRegistryPath, DISPLAY_NAME) - .Contains(MSREDISTR_LIB_VS_2022_NAME); + return vcRegistryPath != null && RegHelper.GetStringValue(RegistryHive.ClassesRoot, vcRegistryPath, DISPLAY_NAME) + .Contains(MSREDISTR_LIB_VS_2022_NAME); + } + catch (Exception) + { + return false; + } } } } \ No newline at end of file