NUnit and XNA on Windows x64

November 17th, 2008

UPDATE: As mike lederle pointed out in the comments, NUnit has had a seperate test-runner executable (nunit-x86.exe) since v2.4.2. This is a much better way to test 32bit code on Windows x64!

I’ve been working on a project using XNA recently, and since I’ve been learning TDD and unit testing I wanted to use NUnit. However, whenever I tried to load the test assembly in the test runner, I’d get the following (rather unhelpful) error:

Could not load file or assembly 'Spladug.Project.Tests' or one of 
its dependencies. The system cannot find the file specified.

After poking around for a while, I discovered that my problem stemmed from being on Windows x64. XNA’s libraries are 32-bit only, which means that despite being .NET, applications (and class libraries) built on XNA are always 32-bit. As described in a post about testing 32-bit applications on Windows x64, you have to configure NUnit to run in 32-bit mode as well to be able to load the test assembly.

To do this, simply run the following command in a console with sufficient permissions and with filenames tweaked as necessary:

C:\>corflags "C:\Program Files (x86)\NUnit 2.5\net-2.0\nunit.exe" /32BIT+

corflags is a utility that comes with the .NET Framework SDK. See the documentation for .NET Framework Tools for more details.

Comments

  1. mike lederle - June 17th, 2009 @ 10:58 am

    Use nunit-x86.exe. Thanks for your post; it saved me from giving up.

  2. Neil Williams - July 17th, 2009 @ 10:21 am

    Ahh I can’t believe I missed that. Thanks for pointing that out =)

Leave a Comment