I have a little confusion on the x86, x64 and Any CPU configuration in Visual Studio 2008 and Visual Studio 2010.
-
One question per question, please. That's why they're called questions. – Lightness Races in Orbit Jan 03 '15 at 20:36
-
@ LightnessRacesinOrbit- The comment I have added is a related issue to the first question , rather than duplicating questions over and over again , I have posted here in my own question. I hope u will understand that tooo . – Sanjeewa Jan 03 '15 at 20:51
-
1What I am saying is that you put two questions in this question, both marked "**Question**" in bold text, "**Question 01**" and "**Question 02**", and that you should not do that. – Lightness Races in Orbit Jan 03 '15 at 20:55
-
@ LightnessRacesinOrbit the same thing i have to say ,"Question 01" and "Question 02" are also related to same topic, i don't like to duplicate questions in to 2 questions , i have put like that way to understand the other readers the question clearly and get some clear answers , that's the main reason , nothing else – Sanjeewa Jan 03 '15 at 21:07
-
1Who said anything about duplicating questions? Write _one question per question_, please. No exceptions. This is not a chatroom or forum: it's a Q&A repository. – Lightness Races in Orbit Jan 03 '15 at 21:17
-
when you post "Question 01" in to one question and "Question 02" to another question , will it not be a duplicate of question , i don't think so , since both are refer to 64 bit 32 bit platform issue . yes i know this is not a chat room , if you not been posting comments on "one question per question..." on my post I would never been go such far... like this commenting on this post at all. – Sanjeewa Jan 03 '15 at 21:25
-
1Sorry but I don't understand what you're saying, and I don't understand how posting _one question per question_ creates "a duplicate of question". – Lightness Races in Orbit Jan 03 '15 at 21:48
-
This *must* have been a duplicate in 2015. Probably one from 2008. What is the canonical question? – Peter Mortensen May 30 '22 at 20:47
-
Related: *[How can I determine if a .NET assembly was built for x86 or x64?](https://stackoverflow.com/questions/270531/)* – Peter Mortensen May 30 '22 at 20:57
2 Answers
How come x86 works on 64-bit Windows 7, Windows 8, and even the server configuration machines that are in 64 bit OS?
Because of WoW64 (Windows on Windows 64-bit). Basically, it is a 32 bit emulator, which allows you to run 32 bit programs in a 64 bit operating system.
X86 vs X64 vs Any CPU: What are the clear differences?
X86 is the mode for 32 bit applications, named after the 80x86 series CPUs. A 32 bit application can address 4 GB of memory.
X64 is the mode for 64 bit applications. It's a shortening of the name x86-64 which is the 64 bit mode of the x86 instruction set. A 64 bit application can address 18 PB (petabyte) of memory, which translates to all available memory (for the forseeable future).
The Any CPU mode allows for compilation to each of the other two modes.
The compilation mode is just an instruction for the JIT compiler for how it is allowed to compile the CIL code into machine code. The CIL code itself is the same for all modes.

- 30,738
- 21
- 105
- 131

- 687,336
- 108
- 737
- 1,005
-
1All the answers above are ok , but when you add anycpu to run the app. on windows 7 or windows 8 or server versions of OS it fails , but changed to x86 runs on 3 of all mentioned OS. How would anyone explain that happen. Need little more clarification . – Sanjeewa Jan 03 '15 at 19:22
-
@Sanjeewa: Then you have something in the application that doesn't work in 64-bit mode. By choosing the x86 mode you are preventing compilation into 64-bit code, so you are circumventing the problem. – Guffa Jan 03 '15 at 20:38
-
@ Guffa yes it's true x86 is working that way, but I'm referring to the **"anycpu"** mode . how come it is not working in win7, win 8 64 bit OS since it allows for compilation to each of the two modes,only when I put x86 it is working but not **"anycpu"** mode – Sanjeewa Jan 03 '15 at 21:00
-
@Sanjeewa: Using `AnyCpu` means that it will compile to 64-bit when available, otherwise 32-bit. The fact that your application happens to fail in 64-bit mode isn't anything that the JIT compiler is aware of, so it can't take that into account. – Guffa Jan 03 '15 at 21:54
Question 1: The 64-bit versions of Windows can run both 32-bit (x86) and 64-bit applications. This is why there are two different C:\Program Files and C:\Program Files (x86) folders to keep applications compiled for the two available CPU architectures apart.
Question 2: The target CPU flag that you set is an indication that the compiled result of the build is targeted to run on the selected CPU architecture. In this case, the Any CPU means that the application can run in the preferred 32- or 64-bit mode of the operating system.
A system that supports 64-bit mode often makes this the preferred mode to run the application. The reason you want to be able to select the mode manually is if you use any component that is already compiled for a specific architecture, the application must use the same architecture as the component. Components in this case might be COM- or ActiveX controls.

- 30,738
- 21
- 105
- 131

- 1,398
- 1
- 14
- 28