Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is an 'Any CPU' application running as x86 on a x64 machine?

I have a Any CPU application installed to Program Files (x86). On one Windows 7 x64 machine, it runs as x64 as expected while on another Windows 7 x64 machine, it runs as x86!

How can this be? I expected it to run as x64 on both machines. What might be the reason and what can I do to always make it run as x64?

Does it matter where I am running it from - Program Files (x86) in my case?

like image 384
BobbyHill Avatar asked Jun 10 '11 10:06

BobbyHill


People also ask

Should I target x86 or x64?

So, target x86 or x64. Since x86 apps run on both x64 and x86 systems, the most compatible choice is to build x86. If you MUST build a 64 bit solution, you'll need to target x64 and use our x64 dlls.

How do I run x86 on x64?

WOW64 is the x86 emulator that allows 32-bit Windows-based applications to run seamlessly on 64-bit Windows. This allows for 32-bit (x86) Windows applications to run seamlessly in 64-bit (x64) Windows, as well as for 32-bit (x86) and 32-bit (ARM) Windows applications to run seamlessly in 64-bit (ARM64) Windows.

What is the difference between any CPU and x86?

"Any CPU" means that when the program is started, the . NET Framework will figure out, based on the OS bitness, whether to run your program in 32 bits or 64 bits. There is a difference between x86 and Any CPU: on a x64 system, your executable compiled for X86 will run as a 32-bit executable.


1 Answers

It's likely that you linked some assemblies that are not Any CPU, but include native code (or are compiled as x86), which cause the entire process to fall back to x86.

To understand how your assemblies are compiled, a related Stack Overflow question that might help is How to determine if a .NET assembly was built for x86 or x64?*.

Note: the location of the executable on the file system does not matter at all.

like image 128
Dario Solera Avatar answered Oct 17 '22 06:10

Dario Solera