Delta Engine Blog

All about multiplatform and game development

Getting XNA to work in Windows XP x64

As some of you might know I am a Windows XP x64 User for a while now. x64 Bit works great and most issues could be resolved one way or another. As I wrote in my Windows x64 post a few weeks back it is very important to make sure Managed DirectX uses always x86 (32 bit) as the target platform. x64 is NOT supported and "Any CPU" will work on 32 bit because it will use x86 automatically, but on x64 bit platforms, x64 will be choosed. Since calling 32 bit dlls (which all Managed DirectX dlls are) is not possible from x64, you have to have your whole app in 32 bit mode!

Same thing for XNA, which uses 32 bit and the release coming out in a few days will also support only x86 (32 bit). Since XNA Game Studio Express is based on Visual C# Express, which does not support switching from Any CPU to x86, it is NOT possible to run any XNA game or XNA code out of the box. While Visual Studio 2005 allows us to switch from Any CPU to x86, we cannot use the templates or even open the XNA projects (you get a error message like "this project type is not supported").

There is a simple trick, which also works for Visual C# Express, if you want to support x64 platforms too (no matter which platform you use yourself):

Add the following line into each PropertyGroup item of your csproj file in a text editor:

  <PlatformTarget>x86</PlatformTarget>

Or if you just want to copy the full PropertyGroups for the default Debug and Release configurations, copy this into your csproj file and overwrite the old Debug and Release PropertyGroups items.

 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <NoStdLib>true</NoStdLib>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <PlatformTarget>x86</PlatformTarget>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <NoStdLib>true</NoStdLib>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <PlatformTarget>x86</PlatformTarget>
  </PropertyGroup>

Now XNA runs fine on x64 bit. Happy developing (ok, you have to wait till the 30. august, haha).

Update: An even better solution might be to directly change the template files located at
C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\VCSExpress\ProjectTemplates\1033\
There you can find the Xna templates as zip files. Just extract them, edit the .csproj files and save it as a .zip file again. I can provide you with the updated .zip files as soon as XNA is released (in case this doesn't get implemented anyways).
Also make sure to update the cache for these files at (just extract the .zip files there):
C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\VCSExpress\ProjectTemplatesCache\1033\

Update 2006-08-30: Download this file (Xna64BitSupport.zip 14 KB)
and extract it to:
C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\VCSExpress\
Thats all. This will replace your XNA Game and XNA Library template .zip and cache files.