Why is OpenSubKey() returning null on my Win 7 64 bit system?

Posted by BrMcMullin on Stack Overflow See other posts from Stack Overflow or by BrMcMullin
Published on 2010-03-17T17:18:39Z Indexed on 2010/03/17 17:21 UTC
Read the original article Hit count: 369

Filed under:
|
|

Has anyone seen OpenSubKey() and other Microsoft.Win32 registry functions return null on 64 bit systems when 32 bit registry keys are under Wow6432node in the registry?

I'm working on a unit testing framework that makes a call to OpenSubKey() from the .net library.

My dev system is a Win 7 64 bit environment with VS 2008 SP1 and the Win 7 SDK installed.

The application we're unit testing is a 32 bit application, so the registry is virtualized under HKLM\Software\Wow6432node. When we call:

Registry.LocalMachine.OpenSubKey( @"Software\MyCompany\MyApp\" );

Null is returned, however explicitly stating to look here works:

Registry.LocalMachine.OpenSubKey( @"Software\Wow6432node\MyCompany\MyApp\" );

From what I understand this function should be agnostic to 32 bit or 64 bit environments and should know to jump to the virtual node.

Even stranger is the fact that the exact same call inside a compiled and installed version of our application is running just fine on the same system and is getting the registry keys necessary to run; which are also being placed in HKLM\Software\Wow6432node.

Any suggestions? Thanks in advance!

© Stack Overflow or respective owner

Related posts about .NET

Related posts about registry