Nunit Doesn't Refresh References

Update: I found today that if you load the options dialog of Nunit and tick 'Disable Shadow Copy (default: Enabled)' Nunit correctly loads the latest references. You need to unload the test project from Nunit when building the dll in Visual Studio to release Nunit's lock on the file. Mystery solved!

We came across a strange problem with Nunit today after innocently removing a property from a class. The dll that contained this class was referenced by our Nunit test dll. After reloading the Nunit test dll in the Nunit GUI our tests kept failing, complaining about the property that had been removed.

Obviously an old version of the referenced dll was being loaded, but where from? We loaded every instance of the dll from every 'bin' folder we could find in our development environment into Reflector, and the property we had removed was correctly missing.

After briefly discussing how spooky and mysterious computers are (this was way better than iRobot :P) we downloaded process explorer. We did a search for our dll (under the 'Find' menu) and sure enough it had been loaded by the Nunit GUI, but it was retrieving the file from:

'c:\documents and settings\[user]\local settings\application data\assembly\dl2\a0y61pov.hde\43h4p05e.rd6\cf3437ea\7bb966b2_bb1ec901\myDLL.dll'

A bit of a mouthful to say the least. After deleting this file and reloading the Nunit test, everything worked perfectly.

Interestingly, Nunit updated the dll in the directory above when the file was missing, but not when the file had been modified. I'm guessing it's some inherent behaviour of Winforms apps to cache a version of referenced dlls but why wouldn't it do the essential house-keeping and refresh modified dll's? If anyone could provide some clarification that would be fantastic. For now we're putting it down to the 'ghosts in the machine'...ooooooo spooky!

I found this post from Jimmy Skowronski after fixing the issue - he had the same problem and describes a good way of viewing what dlls are being loaded by projects in Visual Studio. Why Nunit doesn't update the dll itself is still a mystery.

Jimmy

Related posts

Comments

Add comment


 

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

March 9. 2010 13:57

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010