The other day I came across this problem that I had not seen before. It was to do with running unit tests in Visual Studio 2008. All tests would fail with the exception:
Unit Test Adapter threw exception: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
The strange thing is that the tests would pass when run with debugging on.
It turned out that it was because the target assembly was signed, we had Code Coverage on, AND we did not specify a key for Code Coverage to re-sign with. Code Coverage is disabled in debugging – hence the problem only occurs when running without debugging!
It appears that Code Coverage needs to modify the assembly being tested. If the target assembly is signed, it will need to remove the key token, and re-sign it after it’s done. If you have Code Coverage on for multiple assemblies in the solution, then they will be all be re-signed with the same key. This means that your projects in the solution should be signed with the same key.