64bit Assembly Blues: Now With NUnit Goodness!

I made a terrible mistake this morning.  I decided I wanted to just double-check that my unit tests were still working, given my recent move to a 64-bit version of  Windows, and the subsequent meltdown of my development environment.

In Linds happy-clappy land, I’d get a quick display of green ticks across the board, and feel comfortable that my safety net was still doing its safety-net thing. In Linds horrifying-reality land, various failures broke my expectations harder than a two-tonne heavy-thing.

I won’t bore you all with the boring detail of the full path taken.  Instead, let’s cut to the chase, and leave some notes on what went down.

A 32-bit install of Office triggers a need for a 32-bit Office interface library, triggering a need for the assemblies that rely on it to go 32-bit. This then triggers a need for NUnit testing libraries to be compiled 32-bit. Because I’m the cutting-edge Nunit (currently version 2.6.2) it attempts to run against .Net 3.5 by default. I needed to coax it into running .NET 4.0, by modifying the Nunit.exe.config file as described here.

After all that, I’d be right, RIGHT? Wrong! My familiar old friend BadImageFormatException is back, and out to deny me any and all of the unit-testing love I need:

Testing a 32-bit assembly with a 64-bit NUnit install

Testing a 32-bit assembly with a 64-bit NUnit install

So Nunit was all like:

then I was all like:

Until, in a pique of frustration, I saw the 32-bit version of NUnit sitting in the same Nunit program folder.  I pulled the same trick above for the 32-bit executable’s config file, and tried running the same unit test assembly. Success!

32-bit NUnit version runs your 32-bit Test Assemblies!

32-bit NUnit version runs your 32-bit Test Assemblies!

Note to self… this mixed 32-bit/64-bit chain of dependencies is so very fragile. Must remember to carefully ensure the entire stack is properly aligned (or set up a 32-bit development virtual machine, and leave this dope to the junkies).

Between you and me peeps, I truly hope this is the last of my 64-bit upgrade fallout. After this experience, I’m finding it very tempting to take an attitude in future work to lock down the single architecture the software will support (dictated, probably by 3rd-party library limitations), and ensure that the development environment is fully-set up for it.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s