Sunday, January 25, 2015

Newcomer - why would same code run when compiled with command line csc but fail with visual studio (2013)?

I suspect it's the /platform option. If Visual Studio sets /platform:x86 or /platform:anycpu32bitpreferred, your program will run in a 32-bit process and see the 32-bit Registry view. Without that option, the default is /platform:anycpu, and on a 64-bit version of Windows, your program will run in a 64-bit process and see the 64-bit Registry view.


You could use RegistryKey.OpenBaseKey and explicitly specify the 32-bit or 64-bit view.


No comments:

Post a Comment