13

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.

Brent
  • 4,611
  • 4
  • 38
  • 55
  • Do you have any libraries you have installed with nuget? – DSlagle Jun 06 '13 at 00:31
  • Yes, multiple, and the build messages did occur after updating the libraries. I am not familiar enough with nuget to know how to find/fix this though – Brent Jun 06 '13 at 00:41
  • 5
    Try running update-package -reinstall in the package manager console. You have to have nuget 2.1 installed to do this but it will retarget all your 3rd party libs. Did this on my project a few days ago after updating to .net 4.5. I was having the same type of error message. Check out this link for more info http://stackoverflow.com/questions/12006991/retargeting-solution-from-net-4-0-to-4-5-how-to-retarget-the-nuget-packages – DSlagle Jun 06 '13 at 00:42

3 Answers3

13

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?

Community
  • 1
  • 1
DSlagle
  • 1,563
  • 12
  • 19
  • Thank you DSlagle - was just about to ask you to post so I could accept the answer. I am guessing this will soon be marked as duplicate, but I can see how my searches didn't find your StackOverflow link. – Brent Jun 06 '13 at 01:11
  • just is side note, `Update-Package -Reinstall` would take long time according to your project – mhesabi Nov 02 '14 at 05:43
  • 2
    WARNING - This using this command made most of my references invalid and i had to re-create the solution again. – Rafael Herscovici Jan 07 '15 at 19:59
0

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")
Vadym Kyrylkov
  • 610
  • 5
  • 7
0

Try setting AutoGenerateBindingRedirects to true in the project file.

janw
  • 8,758
  • 11
  • 40
  • 62
Steve
  • 1