visual studio express 2012 app.config remapping assembly
Asked Answered
D

3

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.

Demonstrator answered 6/6, 2013 at 0:23 Comment(3)
Do you have any libraries you have installed with nuget?Antiperspirant
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 thoughDemonstrator
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 #12007491Antiperspirant
A
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?

Antiperspirant answered 6/6, 2013 at 0:47 Comment(3)
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.Demonstrator
just is side note, Update-Package -Reinstall would take long time according to your projectMuss
WARNING - This using this command made most of my references invalid and i had to re-create the solution again.Alabama
H
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")
Hartsfield answered 16/12, 2015 at 13:54 Comment(0)
Z
0

Try setting AutoGenerateBindingRedirects to true in the project file.

Zenaidazenana answered 29/12, 2020 at 15:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.