I came across a bizarre scenario where a 32-bit process claims that its PROCESSOR_ARCHITECTURE is AMD64, which leads to the failure of components making decisions based on this flag.
I highlighted it in the following steps:
- In VS2010, create a library project
- On the tab "Project Properties / Debugging" set "Run external program" in VS exe (for example, C: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ Common7 \ IDE \ devenv.exe)
- Run Ctrl-F5, which launched another instance of VS
- In this second example, create a console application and paste the following code
In the main:
Console.WriteLine(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE")); Console.ReadLine();
- Now run the console application
And it displays AMD64, although this is a 32-bit process (by default for console applications, for build settings).
Question : can others also reproduce this, and if so, can you explain it?
Note: if you are interested, the reason I run VS is because I use an experimental bush for the second instance
UPDATE: note that in my real scenario, I am not looking for this environment variable myself. Instead, I use a component (SQLCE) that looks for it and relies on its correctness.
source share