user721264
user721264

Reputation: 487

GAC assembly reading registry - c#

I have an assembly that installed in the GAC. Can this assembly access registry values in HKEY_LOCAL_MACHINE\SOFTWARE\COMPANYNAME

I do not get any error but am not able to read subkey from above path. My assembly is strongly signed.

Reason I am using registry is because use of config file is not permitted.

Sample code

string regKey = "HKEY_LOCAL_MACHINE\SOFTWARE\COMPANYNAME";
string userGUID = (string)Registry.GetValue(regKey, "userGUID", "-1");

Upvotes: 1

Views: 315

Answers (1)

pabdulin
pabdulin

Reputation: 35225

If you are running 64-bit OS and your assembly is x86, or called by a x86 process, then your registry call is redirected to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\COMPANYNAME node. This can be the source of your problem.

Upvotes: 1

Related Questions