Security Error when accessing Registry

makenna04

New member
Joined
Jun 5, 2006
Messages
1
Programming Experience
Beginner
Hello,


I was wondering if i could get someone to help me. I'm new to VB.Net and Windows programming in general for that matter and am stuck on an issue.

I'm writing a program that creates a simple form, asking for values such as name,username,password, and email. After validating said fields, it writes the username and email to the registry as string values.

Everything works great except when i try to open the Reg key. The block of code looks something like this:

VB.NET:
Imports Microsoft.Win32 'At top of form
 
----------------------------------------------------
 
Dim regAdd As RegistryKey
 
 
regAdd =Registry.CurrentUser.OpenSubKey("Software", True)
regAdd = regAdd.CreateSubKey("PCOpen")
regAdd.SetValue("Username", txtUserName.Text)
regAdd.SetValue("Email", txtEmail.Text)
regAdd.Close()
When i attempt to run this, it produces the following error:
first chance exception of type 'System.Security.SecurityException' occurred in mscorlib.dll

It seems to be failing at this line:
VB.NET:
regAdd=Registry.CurrentUser.OpenSubKey("Software", True)

I've tried running this as administrator but it does the same thing.

If anyone has any suggestions they would be greatly appreciated!

Thank you!


makenna04
 
Last edited by a moderator:
Back
Top