During recent tests on the new hardware I found that the application was no longer able to read from the Registry. First I guessed that the new system's stricter security was a reason. Changing registry key's permissions did not help. Creating a separate IIS application pool and running it under a privileged user account did not help either.
Meanwhile a test application had not trouble enumerating subkeys inside HKEY_LOCAL_MACHINE\SOFTWARE, but strangely it could not access HKEY_LOCAL_MACHINE\SOFTWARE\[MyApplicationRoot]. Strangely it was until I noticed that the enumerated subkeys were not exactly the subkeys the Regedit displayed.
A quick search using the Regedit revealed that HKEY_LOCAL_MACHINE\SOFTWARE enumeration on 64-bit system actually enumerated subkeys inside HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node. That's where I moved the keys of my application and finally had this issue resolved. No source code changes were required.
Read more about registry redirection:
http://msdn.microsoft.com/en-us/library/ms724072(v=vs.85).aspx
Private Sub ListRegistryKeys(ByVal strKey As String)
Dim rk As Microsoft.Win32.RegistryKey = _
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(strKey)
Response.Write("Subkeys:<ul>")
Response.Write(String.Format("<li>{0}", _
System.Security.Principal.WindowsIdentity.GetCurrent().Name))
For Each skName As String In rk.GetSubKeyNames()
Dim sk As Microsoft.Win32.RegistryKey = rk.OpenSubKey(skName)
Response.Write(String.Format("<li>{0}", sk.Name))
Next
rk.Close()
Response.Write("</ul><hr>")
End Sub
No comments:
Post a Comment