2
votes

I have the following question:

My .NET assemblies are compiled in x86 mode. Can I still leverage the performance benefits of NGEN on x64 Windows systems? Will x86 assemblies be compiled into native code on x64?

1
You have to NGEN on the specific target platform, but... Sure - why not? Note: NGEN only reduces JIT ... it helps in some cases, but isn't a magic performance bullet.Marc Gravell♦
Is it necessary to run different NGEN versions depending on the architecture? Or there's a universal one?SharpAffair
Yes, there are two versions of ngen.exe. It needs to be run by your installer. The walkthrough for enabling ngen is here: msdn.microsoft.com/en-us/library/3hwzzhyd%28v=VS.90%29.aspxHans Passant

1 Answers

4
votes

Assemblies compiled with x86 will run i wow64 on 64-bits systems, but assemblies copiled with AnyCPU will run natively, regardless of NGEN. Assemblies compiled for x86 can load 32-bit assemblies on 64-bit systems and code compiled for AnyCPU will not load 32-bit dlls.

When you use NGEN you will avoid JIT-compiling of the assembly and the assembly will be native x86 code when compiled with x86 also on x64 systems.