0
votes

I have a Visual Studio project, that builds fine, and the nunit 2 tests run fine within Visual studio, using the test adapter and / or with 3rd party tools (eg Code Rush, TestDriven.net etc)

However, when I run nunit-console version 2.6.4.14350 on the same project, it fails, with the error below.

System.IO.FileLoadException: Could not load file or assembly 'System.Web.Mvc, Version=4.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) File name: 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

This is true, as I am using System.Web.Mvc Version=5.2.3, but I am still confused about the message

1

1 Answers

1
votes

The reason this works when compiling is that there is a binding redirect in the web.config file on the project.

<dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>

The build and Visual Studio test runners all respect this, but nunit-console does not.

Running msbuild with verbosity:diagnostic will show warnings when this binding redirect is being used.

You can then fix the problem so that everything is pointing at the newest version, and the problem goes away. You can then fix up the