views:

389

answers:

4

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?

+2  A: 

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.

Mitch Wheat
+1  A: 

I've found than when I wrap a native x86 dll the wrapper assembly needs to be compiled for the x86 platform, otherwise I get a BadImageFormatException thrown on a x64 machine. Then it kind of snowballs, since all assemblies referencing that assembly also needs to be compiled for the x86 platform.

It could be that I'm just doing something wrong, but this is what I've found. If I wasn't using native dlls then I would leave all my assemblies as "AnyCPU".

Christo
A: 

I don't know much about .net assemblies, but in general, if you know that a program will only be executed in x64 architectures, compiling it in x64 machine code you'll get some performance improvement, and you will lose nothing (as long as you already know that it will only be executed in x64 environments).

Artur Soler
+4  A: 

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)

Steve