Registry problem

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
 
J

Jason Kester

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top