Registry problem

  • Thread starter Thread starter fabrice
  • Start date Start date
F

fabrice

Hello

I have a little problem by reading personal registry key. I get an error
System.NullReferenceException even if the key exist.
This is my code.

Dim objKey As RegistryKey
objKey = Registry.CurrentUser.OpenSubKey _
("Secure\test", False)

response.Write(Convert.ToString(objKey.GetValue("mytest", "")))

---- If i try to read another key like this, i works fine !

Dim objKey As RegistryKey
objKey = Registry.LocalMachine.OpenSubKey _
("SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" _
, False)
response.Write(Convert.ToString(objKey.GetValue("ComputerName",
"")))


The problem exist only when i create news keys. I don't know why ?
It is acl problem ?


thanks for your help.

fabrice
 
Why CurrentUser and not LocalMachine? CurrentUser would be the ASPNET
account, not your personal user account. It sounds like you're setting
a key for your personal account, and expecting ASP.NET to read it.
That's simply not going to work.

Sounds like LocalMachine works for you. Good. That's where you should
be doing all your registry reading from a Web App anyway. Stick with
it!

Jason Kester
 
Back
Top