views:

908

answers:

5

I have just branched our Common Business Layer projects from the main to a new branch, and included them in a new solution. Everything compiles but when I run the unit tests I get the following error for every single test...

Unit Test Adapter threw exception: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

The strange thing is they run fine when I debug them. The error only happens when I run them without the debugger attached.

Failing an outright fix, can anyone tell me how to "Retrieve the LoaderExceptions property"?

+2  A: 

My psychic debugger says that you're using 64-bit, and your test adapter is set to use 64-bit .NET framework, and devenv is set to 32-bit. Use corflags to force your test adaptor to run using the 32-bit CLR.

NOTE: Psychic debugger is not always 100% accurate, due to its use of psychic powers :)

Paul Betts
Nice! Thanks sooo much. That worked a treat.
Andy McCluggage
+3  A: 

Try cleaning the solution and trying again.

Also try clicking on the link that appears in yellow bar of the Test Results window, this sometimes gives more information about why tests cannot be run.

Si Keep
Cleaning the project fixed the issue for me. Thx!!
irperez
A: 

Nothing to see here, move along....

heisenbug

krusty.ar
+1  A: 

Thanks Si Keep. That helped. I also had to resign the target assembly. I Don't know why. It's a mystery (like some of the answers posted for this question).

Andy McCluggage
+3  A: 

I've also seen this, sometimes when the simple cleanup doesn't help, I switch the configuration to Release, clean it up, then back to Debug, clean it up and rebuild (

Yacoder
In my case THIS solved my problem because my project references were wrong - one of the projects referenced the release DLL of one of the other projects - not the project itself. When something chnaged in that referenced project, BOOM!
n8wrl
Another dead-simple note: Don't try to run unit tests in Release mode.
Zian Choy