I\'ve got a C# .NET class library MyClassLibrary that compiles fine. I\'m trying to create a unit test project for it (using Visual Studio Unit Testing Fram
Happened to me too. In my case the problem arised because the tested project and the unit tests project had the same name. If this is your case too then rename one of the projects and rename output file name to fix it.
I just banged my head against this one for an hour. The problem was that I had a command line project named Something.exe, which was using a class library project named Something.dll.
The MyClassLibrary assembly was set to x86 mode in the configuration manager. Changing this to x64 fixed it. I really wish Visual Studio would detect this and report it as a less obscure error.
This happened to me as well. I had a nuget package installed on my domain project with version 1.5, but only had version 1.1 on my unit test project. I resolved the issue by updating the version on the unit test project to match the version on the domain project (the project being tested against).
I had similar problem as Trey, but instead of BizTalk, I have SharePoint solution which also uses GAC deployment. GAC had an older assembly. When I removed the GAC assembly by retracting the solution, the test passed.
In case this helps others with the same error (I realise it doesn't directly answer the question re Release vs Debug); I merged in a legacy project with a namespace that conflicted with an existing one, so renamed it. I got this error when trying to create a form from that project.
I checked the platform target was the same, and deleted the .\bin\ directories to ensure a clean rebuild, removed the reference to the merged project and re-added it, but still the same error.
Eventually (!) I checked the Assembly Name in the project's properties (right click on project, select 'properties', select the 'Application' tab) and changed that to match the Default namespace, and all is now well.