Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0' or one of its dependencies

Dani Petrick picture Dani Petrick · Jun 4, 2014 · Viewed 70.6k times · Source

I am adding Ninject in MVC project using the following commands in Package Manager Console:

Install-Package Ninject -version 3.0.1.10
Install-Package Ninject.Web.Common -version 3.0.0.7
Install-Package Ninject.MVC3 -Version 3.0.0.6

When I run the application, I get error like this:

Could not load file or assembly 'System.Web.Mvc, Version=3.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)

Answer

amighty picture amighty · Jul 17, 2014

Update the Application web.config File

Be sure to make these changes in the app web.config file, not the web.config file in the Views folder.

 <runtime>
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <dependentAssembly>
             <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
             <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
         </dependentAssembly>
      </assemblyBinding>
 </runtime>