Solved

Returns NULL ... RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\MyCompany");

Posted on 2008-06-12
4
3,372 Views
Last Modified: 2013-11-29
hello,

I am having a problem reading the registry. The following line returns NULL.
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\MyCompany");

Windows XP 64 bit
IIS running 32bit .NET framework and IIS enabled to run 32 bit apps.

Key was created manually using regedit.

I am administrator on this machine.

Any ideas? thanks

BTW, this works
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE");
0
Comment
Question by:Valimai
  • 2
4 Comments
 
LVL 3

Expert Comment

by:aphillips
ID: 21775147
This is a real mystery. It's not a privilege problem as SecurityException would be thrown.

Do other sub-keys work?

  RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft");

Have you tried?

  RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE");
  RegistryKey key2 = key.OpenSubKey(@"MyCompany");
0
 
LVL 1

Author Comment

by:Valimai
ID: 21789809
Yes, I tried the SOFTWARE key only and it returned a result. Any sub folder created cannot be read.

We have since decided that the machine has a problem and will re-install the OS.

If you do not mind, I will ask that this question be deleted.
0
 
LVL 41

Accepted Solution

by:
graye earned 500 total points
ID: 21793114
I wouldn't make that assumption!

The 64-bit version of Windows has a Virtual Registry to maintain backwards compatibility with 32-bit apps.   So, in your case, there are actually two views in the registry with same name.  The 64-bit view is available from inside a 64-bit application, and the 32-bit view is available from inside 32-bit applications.

However,  the .Net Framework does not support the ability to switch to the other "view"... so to see the "other" (32bit from 64bit app, or 64 bit from 32bit app) view, you'd have to use the low-level APIs.   There is an unfinished project out on CodePlex that is designed to be drop-in replacement for the .Net Framework's Registry class that provides this missing feature.

http://www.codeplex.com/Registry64bit
0
 
LVL 1

Author Closing Comment

by:Valimai
ID: 31466787
We have re-installed the machine to 32bit. Your explaination sounds plausable.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question