3

IDE Used :: VS.NET 2015, 2017

Version Upgrade :: 4.5 To 4.6.1

The view code is having some HTML helpers like @Html.TextBoxFor and @Html.PasswordFor. It is showing the red lines underneath them and on runtime the page throws the exception.

My asp.net solution contains more than 30 projects inside. I have upgraded the targeted framework to 4.6.1 . I tried to follow the solution offered in the post VS 2015 IntelliSense: Assembly Not Referenced Error. I tried copying the assembly references inside the web.config, but no luck so far. I tried to open the project in the latest VS.NET 2017 also. But again i am getting the same issue.

Please suggest how to fix these errors. This is getting on my nerves now and i wasted lot of time trying to fix it.

  • The type 'Expression<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

  • 'ModelErrorCollection' does not contain a definition for 'Any' and no extension method 'Any' accepting a first argument of type 'ModelErrorCollection' could be found (are you missing a using directive or an assembly reference?)

enter image description here

Community
  • 1
  • 1
Karan
  • 3,265
  • 9
  • 54
  • 82
  • why have you tagged it with .net core if your question is about 4.6.1? The System.Core assembly != the .NET Core framework. Anyway, my advice would be don't try to upgrade your IDE and framework version at the same time. Do one successfully, then the other (the order is not really important AFAIK). Then you can maybe narrow down the issue. – ADyson May 04 '17 at 09:19
  • Which helpers? Which version? MVC is not part of .NET itself, it's a separate package. Modifying `web.config` won't help if you have the wrong references or use the wrong package version – Panagiotis Kanavos May 04 '17 at 09:50
  • Please find the added screenshot. – Karan May 04 '17 at 09:53

1 Answers1

0

It was a weird issue. There were couple of assembly binding redirects happening in my project and was defined inside the web.config.

  <!--<dependentAssembly>
        <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0"/>
     </dependentAssembly>-->

I commented the above lines in web.config & restarted the VS.NET IDE. And finally the issue got resolved.

Karan
  • 3,265
  • 9
  • 54
  • 82