"Access to the registry key is denied" and OpenRemoteBaseKey

J

Jenna

In my test form, WebForm1.aspx.vb, this code successfully connects to
the remote registry:

Try
Dim RegTo As Microsoft.Win32.RegistryKey =
Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine,
"srvtest")
Catch ex As Exception

End Try


but this code doesn't (RegTo is equal to Nothing):

Dim RegTo As Microsoft.Win32.RegistryKey
Try
RegTo = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine,
"srvtest")
Catch ex As Exception

End Try


As you can see, I just moved the declaration! Does anyone know why
this code does not work? I also have <identity impersonate="true" />
set in the web.config file.
 
K

Ken Cox [Microsoft MVP]

I'm curious as to what the exception says after the first example.

Is it possible that you aren't connecting there but the Try...Catch is
eating the exception so you don't see it?
 
J

Jenna

Actually, the exception is the same after both examples. I put dummy
code in for the Catch (i.e. sender=sender for the Button1_Click event)
and the code went into the exception in both examples.

On both:
ex.Message = "Access to the registry key is denied"
ex.Source = "mscorlib"
 

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,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top