We’ve just solved a tricky thing in our project. We still don’t get what is happening under the covers but now we’ve got it to work.
When we ran our unit tests (99% code coverage have I mentioned that :)) in the Visual Studio IDE everything was green and nice. However when the tests were run in our build script they failed with some strange reference problem. The same thing happened if we ran the test local via MSTest.exe.
OK - we then found the following post that showed us the same behavior. The solution is to in the .testrunconfig-file for the test configure DeploymentItems that points to any additional reference you need for your test to run.
Via the Test->Edit Test Run Configuration-menu item you can easily add files and folders.