Stuck on a single error
System.NullReferenceException: 'Object reference not set to an instance of an object.'
RSK was Nothing.
Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Listname()
    End Sub
    Private Sub Listname()
        Dim soft As String() = Nothing
        Dim softkey As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products"
        Using RSK As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(softkey)
            For Each RSKName As String In RSK.GetSubKeyNames
                'get sub key
                Dim name = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(softkey).OpenSubKey(RSKName).OpenSubKey("InstallProperties").GetValue("DisplayName")
                Dim installlocal = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(softkey).OpenSubKey(RSKName).OpenSubKey("InstallProperties").GetValue("InstallLocation")
                Dim pub = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(softkey).OpenSubKey(RSKName).OpenSubKey("InstallProperties").GetValue("Publisher")
                Dim Uninstall = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(softkey).OpenSubKey(RSKName).OpenSubKey("InstallProperties").GetValue("UninstallString")
                If name.ToString <> "" Then
                    Dim lst As New ListViewItem
                    lst.Text = name.ToString
                    lst.SubItems.Add(installlocal.ToString)
                    lst.SubItems.Add(pub.ToString)
                    ListView1.Items.Add(lst)
                End If
            Next
        End Using
    End Sub
End Class
I expect the output to show all the installed programs in listview but the actual output is this error
System.NullReferenceException: 'Object reference not set to an instance of an object.'
RSK was Nothing.
 
     
    