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


Today i was debugging the code, it was written like this


 string _retValue = "";
            Microsoft.Win32.RegistryKey _rKey;
            Object _rKeyObject;
            string REG_KEY_PATH_PROFILE = "SOFTWARE\\Wow6432Node\\Mycompany\\e-business\\Platform\\profile\\";
            try
            {
                _rKey = Microsoft.Win32.Registry.LocalMachine;
                _rKeyObject = _rKey.OpenSubKey(REG_KEY_PATH_PROFILE).GetValue(keyName);
                _retValue = Convert.ToString(_rKeyObject);
                return _retValue;
            }

It was returning null value every time, then i came to know i am building the application on 64 bit, To make the work around we can change project setup like this given below

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: