Question

I moved a project from MVC 3 to MVC 4 a while ago now.

when I build, I get the messages

1>  No way to resolve conflict between "System.Web.Mvc, Version=3.0.0.0 ..." and , Version=2.0.0.0
1>  Consider app.config remapping of assembly "System.Web.WebPages ..." from Version "1.0.0.0" to Version "2.0.0.0"  to solve conflict and get rid of warning.
1>  Consider app.config remapping of assembly "System.Web.WebPages.Razorfrom Version "1.0.0.0" [c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Razor.dll] to Version "2.0.0.0" [C:\Users\OEM\documents\visual studio 2012\Projects\DabTrial\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Razor.dll] to solve conflict and get rid of warning.

and so on.

When I look at references, they are all the later versions, and the web.config only refers to the later versions. When I search the entire solution directory by the public key token (in windows explorer) I find no XML type files with references to the earlier versions.

obviously the path to the files is different, but I cannot find where the compiler is being directed to the path for the earlier .dll file.

The project builds and runs fine, but I assume the compiler is suggesting these changes for a reason. Thanks for any help.

Was it helpful?

Solution

Your nuget dependencies are probably referencing the MVC3 version. You can try putting the following into your web config to force the MVC4 version:

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

You could also try running the following in the Package Manager Console

Update-Package -Reinstall

You have to have at least version 2.1 of nuget for this command but it will update your packages and retarget them if you have updated .NET. You can check this post for more information.

Retargeting solution from .Net 4.0 to 4.5 - how to retarget the NuGet packages?

OTHER TIPS

I also had such problems. I did just two things:

  • updated System.Web.Mvc and all dependencies to the last version (5.2.3)
  • Rebuild all solution (I did using "Solution -> Clean Solution", then "Solution -> Build Solution")

Try setting AutoGenerateBindingRedirects to true in the project file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top