XNA2.0 Dependency checking

After a lot of trial and error using Process Monitor and Virtual PC, I have finally sussed out exactly what XNA2.0 games on Windows need to run. The requirements are slightly different to XNA 1 games.

Direct X runtimes

There are four files that need to be installed in the system32 folder for XNA to initialise properly. They are:

  • xinput1_3.dll
  • x3daudio1_3.dll
  • d3dx9_31.dll, and
  • xactengine2_9.dll

The first three can be placed alongside the application exe and then load fine, but xactengine2_9.dll does not load this way for some reason, and has to be present in the system directory. Distributing these files alongside the application breaks the DirectX EULA, so they have to be installed using dxsetup.exe.

To check the presence in your XNA game, just put this code in Program.cs before game.Run() is called:

bool HasAllPrereqs = true;
// check all the required files, if any missing, return false
if (!System.IO.File.Exists(System.Environment.SystemDirectory 
    + "\\xactengine2_9.dll")) HasAllPrereqs = false;
if (!System.IO.File.Exists(System.Environment.SystemDirectory 
    + "\\d3dx9_31.dll")) HasAllPrereqs = false;
if (!System.IO.File.Exists(System.Environment.SystemDirectory 
    + "\\x3daudio1_2.dll")) HasAllPrereqs = false;
if (!System.IO.File.Exists(System.Environment.SystemDirectory 
    + "\\xinput1_3.dll")) HasAllPrereqs = false;

If HasAllPrereqs is false after those lines, exit the application before it crashes horribly when XNA tries to initialise.

Visual C++ 2005 SP1 runtimes

Even a fresh Vista install doesn’t have these. They are provided when updating Visual Studio 2005 to SP1, or installing SP1 of the .Net Framework 2.0. However, Vista comes with SP0 of .Net 2.0, meaning 99% of machines you come across will be lacking what XNA 2.0 needs. There is a 2.5MB standalone installer on the MS download site here which installs what you need even on .Net 2.0 SP0 machines. .Net 3.5 installs Net 2.0 SP1.

So if any of the following are installed, we safely have the right Visual C++ 2005 runtimes:

  • .NET Framework 2.0 SP1
  • .NET Framework 3.5
  • Visual C++ 2005 SP1 Redistributable

By looking up the product codes in the registry, we can also check at runtime if we have the runtimes (again, before game.Run()):

public static extern Int32 MsiQueryProductState(string szProduct);

…goes before the main application entry point, and

bool vccOK = false;
// check for VC++ 2005 SP1 redist (very rare in the wild)
if (MsiQueryProductState(
"{7299052b-02a4-4627-81f2-1818da5d550d}") == 5) vccOK = true;
// check for .NET Framework 2.0 SP1
if (MsiQueryProductState(
"{2FC099BD-AC9B-33EB-809C-D332E1B27C40}") == 5) vccOK = true;
// check for .NET Framework 3.5 (includes 2.0 SP1)
if (MsiQueryProductState(
"{B508B3F1-A24A-32C0-B310-85786919EF28}") == 5) vccOK = true;

If vccOK is still false, exit the application before you call game.Run().

Free pro Microsoft tools for students


Wow. Microsoft has just launched “DreamSpark” – a programme that lets higher education students download pro Microsoft development tools – not the cut-down Express versions of Visual Studio, but the full Professional editions. UK Microsoft student champ Ed Dunhill sums it up the best on his blog here.

You get access to:

  • Visual Studio 2008 Pro
  • The whole Expression suite
  • SQL Server 2005 Developer edition
  • Windows Server 2003 Standard (and hopefully soon 2008)
  • The best bit is a whole years XNA Creators Club subscription FREE! This costs £65 normally with no real free alternative to get games running on the Xbox.

This is evidently a battle against pirated versions of the above products and this is the perfect way to do it. To enroll in the programme, your University needs to provide a Single Sign On authentication system to verify you or you need a ISIC card or NUS Extra card. Unfortunately, Oxford Brookes doesnt have a SSO Auth system (and I doubt they ever will – Oxford Uni does though) so I have had to order an NUS Extra card for a tenner to get in. Your status as a higher education student needs to be verified once a year, so students leaving Uni soon should sign up quick. Other than the XNA Creators Club subscription, I don’t think the products have time limits.

Expect Adobe to follow suit soon with their products if they want to get students hooked – although the academic discounts on Adobe CS3 stuff are great (only £400 for the Master Suite, down from £2500…) students will still pirate. Give students free access to professional tools and they’ll get hooked on them and buy them when they are earning a living.

Taskbar invisible over Remote Desktop

I frequently use Remote Desktop (RDP/Terminal Services) to access my machines running Vista SP1 RTM. 90% of the time, after connecting, I get this annoying problem with the Start bar:


Only the Start button itself is visible.

  • This happens on all my Vista machines, both SP0 and SP1
  • This happens no matter what version of Remote Desktop I am using, the XP version or the “new” Vista one
  • It only appears to happen when the computer was originally using the Aero DWM composition engine and originally in a different resolution to what I am asking the Remote Desktop session to render
  • It happens wether or not the taskbar is at the top or bottom of the screen

So far the only way to get the taskbar back I have found is to click the lonely Start button, click Windows Security, choose Start Task Manager, kill the explorer.exe process and start it again in the Task Manager from File > Run.

Subsequent Remote Desktop connections are then fine, but logging back into the machine from the console then back into Remote Desktop makes it disappear again. A bit frustrating, to say the least.