/Platform:AnyCPU, /Platform:x64, /Platform:x86, what do they mean

When we build a .net solution, we often see the Platform choice in the configuration manager:

image

Besides AnyCPU, other choices are x86 ,x64, and Itanium. What do they mean? According to MSDN, “Anycpu” compiles the assembly to run on any platform while the other 3 choices compiles the assembly for 32 bit, 64 bit x64 and 64bit Itanium respectively.

On a 64-bit Windows operating system:

  • Assemblies compiled with /platform:x86 will execute on the 32 bit CLR running under WOW64.

  • Executables compiled with the /platform:anycpu will execute on the 64 bit CLR.

  • DLLs compiled with the /platform:anycpu will execute on the same CLR as the process into which it is being loaded.

If a .net application uses any 32 bit ActiveX component, it will not be able to load the component in-process. We have two choices:

  1. Host the 32 bit component in an external process, such as COM+ Server Application, or
  2. Run the .NET application as a 32 bit application.

The VBScriptTest project in ASP Classic Compiler contains an unmanaged test. It hosts the msscript.ocx so that I can compare my .net implementation of VBScript against the original VBScript engine from Microsoft. In order to use the 32 bit msscript.ocx, I need to run my unit test in a 32 bit process. NUnit has a 32 bit version of the test runner call NUnit-x86.exe. To use the 32 bit runner, I registered new shell extension as shown below so that I can use the “Run 32 bit NUnit” context menu to invoke the 32 bit NUnit test:

image

Lastly, how to run ASP.NET in 32 bit? It turned out that this is controlled by the Application Pool. If I set the “Enabled 32 bit Application” to true in the Advance Property Setting of the application pool, the ASP.NET application will run in 32 bit.

image

2 Comments

  • •Executables compiled with the /platform:anycpu will execute on the 64 bit CLR.

    Didn't you meant /platform:x64?

  • Paulo, what I said was correct. Executables compiled with the /platform:anycpu can run on both 64 bit OS and 32 bit OS. They will execute on the 64 bit CLR on a 64 bit OS and on the 32 bit CLR on a 32 bit OS. Executetables compiled with /platform:x64 will only run on 64 bit OSes; they will not run on 32 bit OSes.

Comments have been disabled for this content.