Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft Fakes test project could not load assembly

I have a unit test project in a solution that uses Microsoft fakes, and when I build it get the error below. The DLL that it is complaining about being not able to load is on the disk. I've built with Fusion logging turned on and that indicates that the binding was successful, so now am stuck. Any one else had problems with Fakes?

could not load assembly Logging at C:\src\Application\Development\Main Development Branch\Source\Common Library\Logging\bin\Debug\Logging.dll
like image 546
Andy Davies Avatar asked Jan 09 '14 17:01

Andy Davies


People also ask

What does add fakes Assembly do?

When you click on “Add Fakes Assembly” it will create the same assembly again with the Fakes keyword added that we will use for our testing purposes. The Fakes framework uses delegate-based methods for writing code.

What is Microsoft Fakes?

Microsoft Fakes helps you isolate the code you're testing by replacing other parts of the application with stubs or shims. The stubs and shims are small pieces of code that are under the control of your tests.


2 Answers

I also have the same problem with one of my assemblies. According to Microsoft Connect this seems to be a bug which will be "included in next Visual Studio release".

As Gleno correctly added, there is a description for a workaround on the Microsoft Connect website now. Removing the .messages from the FakeAssemblies folder also worked for me, so this should be working for others as well. You may have to click the Show All Files button in your Solution Explorer to be able to see the folder.

Please use your account to upvote the bug in Microsoft Connect if you are interested in a fix earlier than the "next Visual Studio release".

like image 82
Gorgsenegger Avatar answered Oct 20 '22 04:10

Gorgsenegger


Apparently there is a bug in visual studio. What you need to do is to manually remove .messages file in FakeAssemblies folder, which should be inside your project directory. If this persists a workaround could be to add deletion to pre-build events.

like image 36
Gleno Avatar answered Oct 20 '22 04:10

Gleno