Razor views show warnings CS1702 after upgrading to Microsoft.AspNet.Mvc version 4.0.40804.0
Asked Answered
S

1

4

I have changed all web.config files so that 4.0.40804.0 is referenced.

I have a assembly binding redirect in my web.config

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

There are two external assemblies that are built with a previous version of System.Web.Mvc, it's is complaining on one of them (one contains serveral HTML helpers). Can not upgrade them because they are not under my control.

Don't understand why binding redirect is not working for this.

(update: I'm using VS2015)

Sheers answered 21/3, 2016 at 8:0 Comment(0)
S
4

In order to solve this problem I performed the following steps:

  1. Upgrade MVC to the latest version 5.2.3.0
  2. Changed all versions of web.config and checked assembly binding redirects like mentioned in the steps on Upgrade MVC4 to MVC5
  3. Upgrade ASP.NET and Web tools and Microsoft ASP.NET Web Frameworks and Tools in Extensions and Updates
  4. Changed <Project ToolsVersion="12.0" ...> to <Project ToolsVersion="14.0" ... > in web app .csproj AND web app .csproj.user file !

Step 1 and 3 may not be absolutely neccessary if you want to stick to System.Web.Mvc 4.0.0.1. In this case in step 2 you should change version number according to the versions for mvc4.

Step 2 also does not mention Razor dll's or other MVC related dll's. If they are upgraded (e.g. System.Web.Razor 3.0), then you need to change version numbers for these dll's as well in all web.config files.

Finally it was changing the ToolsVersion in .csproj and .csproj.user file that made the warnings go away. The .csproj.user file is particulary tricky, because in our case it is not checked in in source control, meaning every team member has to repeat it for their own .csproj.user file.

Sheers answered 26/3, 2016 at 15:26 Comment(1)
I get this with VS2015 Update 3 with Core projects. I close and reopen VS to cure it.Florencio

© 2022 - 2024 — McMap. All rights reserved.