Update: There is a new post on this subject regarding the Surface SDK SP1, and it’s also verified working on Win7 x64 too
If you are lucky enough to have access to a Surface and/or it’s corresponding SDK, you may have tried to install that SDK on a 64bit Vista installation. If you did you will have been greeted by the following delightful error message:
"Your system does not have the correct version of Windows Vista. You must install Microsoft Surface SDK 1.0 on a 32-bit version of Windows Vista Business, Windows Vista Enterprise, or Windows Vista Ultimate with Service Pack 1 (SP1)."
Rather than grab a different machine with a 32bit install, I thought I’d see whether it was possible to get it up and running on x64. Although it turned out to be quite simple to get working, with no registry hackery required, there may be good reasons why this configuration isn’t supported, so use these instructions at your own risk!
To get things up and running you will need the following:
- Orca – An MSI editor that is part of the Windows SDK. You can grab from the Microsoft download page, or wherever your search engine of choice takes you.
- Visual Studio 2008 – You might be able to use C# Express, but I haven’t tried it.
There is nothing particularly nasty in these instructions, but it does involve using the command line.
Step 1 – The MSI
Firstly we need to use Orca to tweak the launch conditions of the MSI. Make sure you’ve installed all of the SDK pre-requisites first, then walk through the following:
- Install Orca (link above, or just search for it).
- Copy the SurfaceSDK.msi to somewhere on your hard disk, and make sure that it’s not Read Only.
- Right click on the MSI and choose Edit with Orca. This will trigger a UAC, but it’s software from Microsoft, so you should be ok to trust it
- Select "LaunchCondition" in the left hand list, then select "Install OR NOT VersionNT64" in the right hand list (see below).
- Press delete and click OK when asked to confirm the row delete.
- Click Save on the toolbar.
Now if you launch are freshly edited MSI you should be able to install it just fine – hurrah! If you try and launch the simulator though then it will crash almost immediately – boo!
We will fix that though in Step 2…
Step 2 – The Simulator
The reason for the almost immediate crash is due to the assemblies being built for "Any CPU", while relying on a library than only exists for x86. When the simulator starts up it launches in 64bit mode and, because you can’t mix x86 and x64 assemblies, it tries to load the x64 version of XNA (which doesn’t exist) and promptly falls over in a giggling heap.
If this was an app we had written, we could simply change the configuration in Visual Studio to x86 and everything would be rosy (more on this later). Unfortunately I don’t happen to have the source code for the SDK knocking around, so we have to resort to a utility that comes with Visual Studio called CorFlags to force everything to load in 32Bit mode. The following instructions assume you have everything installed in default locations, but they should be easily adaptable if you don’t:
- Go and find the "Visual Studio 2008 Command Prompt" from your start menu (All Programs, Visual Studio 2008, Visual Studio Tools) right click on it and choose "Run as administrator" (accepting the resulting UAC prompt).
- Change to "C:\Program Files (x86)\Microsoft SDKs\Surface\v1.0\Tools\Simulator".
- Enter "corflags SurfaceSimulator.exe /32bit+ /force" (without the quotes). We need to use /force because the assemblies are strong named signed, and altering them this way will invalidate that signature. This is unfortunately unavoidable, but I haven’t found any problems from doing so. You will receive a CF011 warning informing you of this
- Change to "C:\Program Files (x86)\Microsoft Surface\v1.0".
- Use the same corflags syntax from step 3 on the following files, one by one: Attract.exe, AttractConfig.exe, SurfaceInput.exe, SurfaceOutOfOrder.exe, SurfaceShell.exe.
- Close the command prompt and launch the simulator!
Now we’re at this point we need to make sure our Surface applications are set to run in 32Bit mode, or they will just crash when we launch them. This is very simple to do in Visual Studio, and changing this is usually the first step in troubleshooting any weird and wonderful x64 development glitches.
Step 3 – Our Applications
Setting our applications to 32Bit is extremely easy. You may think this is crippling our applications a bit, but all of the Surface units are running Vista 32 so it really doesn’t make a difference (other than making them work on x64!)
- Launch Visual Studio 2008, and either open a solution or create a new one.
- Enter Configuration Manager (if you drop down the "Any CPU" box, there’s an option in there).
- Under "Active solution platform", select
- Select x86 as the Type, Copy settings from Any CPU and make sure "Create new project platforms" is selected:
- Click OK
The Platform column for each of your projects should now read "x86", and you should be able to launch your Surface applications in the simulator.
Job done! 😀
As I said earlier, there may be good reasons why x64 isn’t a supported platform, so this method falls strictly in the "it works on my machine" camp.