Cannot write to the registry key

I'm getting the following error when I try to write to the Vista registry:

System.UnauthorizedAccessException was unhandled
  Message="Cannot write to the registry key."
       at Microsoft.Win32.RegistryKey.EnsureWriteable()
       at Microsoft.Win32.RegistryKey.SetValue(String name, Object value, RegistryValueKind valueKind)
       at RegistryCheck.Program.Main(String[] args) in C:\RegistryCheck\Program.cs:line 75
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

I'm runing Visual Studio as Administrator but this doesn't make a difference.  What am I missing - both for the sake of debug and as a final executable?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Please take a look at the last post of this thread, this should help you: 
John500Author Commented:
Thanks.  The last post goes like this:

Sorry if I wasn't clear, but you have to enable "registry object access"
auditing, that is from regedit select the key you want to audit and add the
user or group you want to monitor. Then, using "Local Security Policy"
editor, you must turn-on; Local Policies - Audit Policy - Audit Object
Access for Failure. When done, each unsuccessful access will be logged in
security log and will contain the account used to modify a key or subkey.

Can you interpret this for me?  How is this done?  The writer states the requirement but doesn't demonstrate it.
Try and disable the UAC first following these instructions: 

This article also explains what vista changed regarding the administrator account...
Acronis Data Cloud 7.8 Enhances Cyber Protection

A closer look at five essential enhancements that benefit end-users and help MSPs take their cloud data protection business further.

John500Author Commented:
The UAC is turned off but this doesn't make a difference.  As I said, I'm also running Visual Studio as administrator.

The article doesn't talk about C# code or .Net provisions for this problem......
Please follow the instructions here:
John500Author Commented:
I don't get it - this article talks about enabling Auditing.  If you want to log the changes that occur on a particular item then these steps would apply but not to C# code that needs access to the registry.
This is an app your creating correct? Did you set the OpenSubKey() function to true ? (sorry about the other posts, got it confused with another answer I am working on :)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
John500Author Commented:
No, I didn't and that was the problem.  Thanks!

How about taking a look at this question too please!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.