tags:

views:

460

answers:

2

Evey now and then I see both x86 and x64 versions of a .NET assembly. Consider the following web part for SharePoint. Why wouldn't the developer just offer a single version and have let the JIT compiler sort out the rest? When I see these kinds offering is it just that the developer decided to create a native image using a tool like ngen in order to avoid a JIT?

Someone please help me out here, I feel like I'm missing something of note.

Updated

From what I got below, both x86 and x64 builds are offered because one or more of the following reasons:

  1. The developer wanted to avoid JITing and created a native image of his code, targeting a given architecture using a tool like ngen.exe.

  2. The assembly contains platform specific COM calls and so it makes no point to build it as AnyCPU. In these cases builds that target different platforms may contain different code.

  3. The assembly may contain Win32 calls using pinvoke which won't get remapped by a JIT and so the build should target the platform it is bound to.

+6  A: 

If they are using specific non-.Net API, then there may be two code bases for this, a perfect example is COM controls.

ngen is also another very good reason for this as you mentioned.

Tom Anderson
... and probably P/Invoke stuff too.
David Schmitt
+5  A: 

When you compile a .net application you have to pick a Platform Target in the Build Settings. The choices are AnyCPU, x86 and x64.

A common bug is to specify AnyCPU in a project which includes native DLLs compiled for x86. This will lead to errors when run on 64-bit machines, a good reason to test on a 64 bit machine.

Therefore, to support people who are forced by their other dependencies to build for x86 or x64 directly, the assembly offers both.

Andy Dent