x64 Development with .NET
At the beginning of this year, I switched to a 64-bit operating system - Vista Ultimate x64, to be exact. For the most part, this process was relatively painless, but there were a few hiccups along the way (mostly x64 compatible drivers, but that's not the point of this discussion).
There were several problem points in the x64 development world that I thought I would describe here. This list is likely to grow, so expect future posts on this.
In the beautiful world of .NET development, applications and builds can be compiled for different platforms. By default, applications and assemblies compile like any processor in Visual Studio. In this case, the CLR will load the assembly as any default target for the machine on which it runs. For example, when you run an executable on an x64 machine, it will run as a 64-bit process.
Visual Studio also provides 3 target platforms: x86, x64, and Itanium (IA-64). When creating an executable file as a specific target, it will be loaded as a process of this type. For example, x86 executable running on an x64 machine will run as a 32-bit process using the 32-bit CLR and WOW64. When assemblies are loaded at run time, they can only be loaded by a process if their purpose matches the host of the process or compiled like any processor. For example, if x64 was set as the build target, it can only be downloaded using the x64 process.
This went into several scenarios for me:
XNA - XNA is only available as a set of 32-bit assemblies. Therefore, referring to XNA assemblies, the executable / assembly using them should be aimed at the x86 platform. If it is designed as x64 (or like any processor and runs on a 64-bit machine), an error will occur when trying to load XNA assemblies.
Microsoft Robotics Studio - XInputGamepadService uses XNA internally to talk to the Xbox 360 controller. See above.
Managed by DirectX. Although it is already deprecated and replaced by XNA, it still uses it. These assemblies were not marked for a specific purpose, however, I had difficulties with memory exceptions, especially with the Microsoft.DirectX.AudioVideoPlayback assembly.
Phidgets - depending on which library you download and when it may or may not be marked as 32-bit only. The current version (11/8/07) is marked as such, so a 32-bit process is required to host it. The easiest way to determine if an executable or assembly is targeting a specific platform is to use the corflags application. To use this, open the Visual Studio command prompt on the Start menu and run it against the assembly you want to test.
The easiest way to determine if an executable or assembly is targeting a specific platform is to use the corflags application. To use this, open the Visual Studio command prompt on the Start menu and run it against the assembly you want to test.