Solved

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

Posted on 2008-06-12
4
3,366 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

Are your corporate email signatures appalling?

Is it scary how unprofessional your email signatures look? Do users create their own terrible designs and give themselves stupid job titles? You can make this a lot easier for yourself by choosing an email signature management solution from Exclaimer today.

Question has a verified solution.

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

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…
This is an article about Leadership and accepting and adapting to new challenges. It focuses mostly on upgrading to Windows 10.
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now