Skip to content

Commit 4f90662

Browse files
committed
old VS detection stabilization
1 parent ae8ffa5 commit 4f90662

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

VisualStudioOpener/VisualStudioDetector.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ private static string CheckOldVisualStudio(RegistryKey key)
2828

2929
private static IEnumerable<IVisualStudioInfo> DetectOldVisualStudios()
3030
{
31-
RegistryKey registryHive = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
32-
31+
using (RegistryKey registryHive = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
3332
using (RegistryKey key = registryHive.OpenSubKey(@"SOFTWARE\Microsoft\VisualStudio", false))
3433
{
3534
foreach (string subKeyName in key.GetSubKeyNames())
@@ -40,6 +39,8 @@ private static IEnumerable<IVisualStudioInfo> DetectOldVisualStudios()
4039

4140
using (RegistryKey subKey = key.OpenSubKey(subKeyName, false))
4241
{
42+
if (subKey == null)
43+
continue;
4344
string path = CheckOldVisualStudio(subKey);
4445
if (path == null || !File.Exists(path))
4546
continue;

0 commit comments

Comments
 (0)