Solved

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

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
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…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…

746 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

11 Experts available now in Live!

Get 1:1 Help Now