I have Moq nuget package installed from Manage Nuget Packages for my project. Project builds successfully but when i run the test case, it throws following error
System.IO.FileLoadException: Could not load file or assembly 'Moq, Version=4.2.1502.911, Culture=neutral, PublicKeyToken=69f491c39445e920' or one of its dependencies
I checked project references and Moq.dll is there.
Also i noticed this on output window for test run
------ Discover test started ------
Unable to load the test container 'C:\dev\tfs\Main\GUI\Gui.Client\Bin\Debug\Gui.Client.dll' or one of its dependencies. Error details: System.IO.FileNotFoundException: Could not load file or assembly 'System.Windows, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Practices.Prism, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
System.IO.FileNotFoundException: Could not load file or assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.
========== Discover test finished: 20 found (0:00:03.4941998) ==========
------ Run test started ------
Warning: conflict during test run deployment: deployment item 'c:\dev\tfs\main\gui\test\gui.client.state.tests\bin\debug\Moq.dll' directly or indirectly referenced by the test container 'c:\dev\tfs\main\gui\test\gui.client.state.tests\bin\debug\gui.client.state.tests.dll' cannot be deployed to 'Moq.dll' because otherwise the file 'c:\dev\tfs\main\gui\test\gui.client.state.tests\bin\debug\Moq.dll' would overwrite deployment item '..\ThirdPartyLibraries\NuGetPackages\Moq.4.2.1402.2112\lib\net40\Moq.dll' specified by the test settings.
Warning: Test Run deployment issue: The assembly or module 'NMath' directly or indirectly referenced by the test container 'c:\dev\tfs\main\gui\test\gui.client.state.tests\bin\debug\gui.client.state.tests.dll' was not found.
========== Run test finished: 1 run (0:00:23.2373118) ==========
Had the same problem. Updated the Moq nugets for all projects to they all use the same Moq library and it worked fine for me.
right click on your Moq reference and make sure that you are using the same version everywhere. if not update the using nuget package manager
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With