Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any advantages to compiling an assembly as x64?

Suppose I have a .Net Framework 3.5 SP1/CLR 2.0 application which needs to run on both x86 and x64 platforms. Suppose as well that for whatever reason, I need to create separate x86 and x64 installation programs.

As I have an x64-specific installer anyway, would there be any benefit to recompiling the application itself as x64 rather than targeting "AnyCPU"?

Does setting the target to x64 change anything at all besides the header information of the generated assembly?

like image 231
Joergen Bech Avatar asked Jun 07 '09 13:06

Joergen Bech


People also ask

Should I build for 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.

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.


2 Answers

If you specify x64 it changes some default memory settings for the program, making it slightly more performant in programs with a large memory pressure. Larger thread stacks are allocated when compiling with x64 (link)

like image 66
Steve Avatar answered Oct 06 '22 00:10

Steve


As long as you are not Ngen'ing any assemblies it would be better to leave as "AnyCPU", and let the JIT target the architecture.

like image 38
Mitch Wheat Avatar answered Oct 05 '22 23:10

Mitch Wheat