Reputation: 1781
I'm developing an ASP.NET MVC 5 app and it works as expected.
Now trying to unit test one controller in the test project when I run it I get the following exception
An exception of type 'System.IO.FileLoadException' occurred in ControlCompras.UnitTests.dll but was not handled in user code
Additional information: Could not load file or assembly 'System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
However the version of System.Web.Mvc.dll that is referenced in the Test project is 5.2.2.0. It's the same assembly that's referenced by the ASP.NET project.
Why it's trying to load the version 5.0.0.0?
Can someone please give me a clue about how to solve this?
Here's what I've tried:
Thanks in advance.
Upvotes: 0
Views: 464
Reputation: 11
I had the same error. I tried updating "System.Web.Mvc" package from nuget package manager in the unit test project. But it didn't reflect any change in references to the unit test project. Heres my solution:
I replaced it with dll file of "System.Web.Mvc" package found from main project.
It worked. Though it's not proper way for upgrading pages but its quick.
Upvotes: 1
Reputation: 1829
I just encountered this error. But I was able to fix it by updating the nuget packages for both the asp.net project and unit test project. Nuget will update both references. The conflict may not occur in System.web.Mvc but in other files as well.
Upvotes: 0