Is there a way in .NET (3.5 or less) to tell if a console application is running on x86 or x64?
Asked
Active
Viewed 516 times
3 Answers
12
IntPtr.Size == 8 // 64bit
If you don't mind to use interop, this function would help: IsWow64Process (example)

aku
- 122,288
- 32
- 173
- 203
3
Do you mean the machine or the process? Why do you want to know?
Aku's answer will tell you if the process you are in is running in a 64bit mode. On current versions of Windows this could mean either Itanuim or x64.
Your process won't necessarily be 64 bit even on a 64 bit machine/OS.
Othewise Microsoft.Build.Utilities.ProcessorArchitecture.CurrentProcessArchitecture returns a string with the current proc arch. It's in 3.5.

Fowl
- 4,940
- 2
- 26
- 43
-
Then there's the OS architecture... (eg. on 32bit Windows running on a 64bit processor) – Fowl Jul 04 '12 at 03:44
0
How about if I have an x64 and an x86 binary dependency on a console application.
Is there a way of deciding at runtime which reference is used dependant on whether we are running on x64 or x86?

dagda1
- 26,856
- 59
- 237
- 450
-
You may want to check out this question/answer for a similar scenario: http://stackoverflow.com/questions/108971/using-side-by-side-assemblies-to-load-the-x64-or-x32-version-of-a-dll#156024 – Milan Gardian Jan 23 '09 at 04:45