0

I have been using Visual Studio 2015 with no problems for over a year now. One of the MVC.net projects that was originally developed on VS 2010 and upgraded to VS 2015 has red error lines on all HTML helpers in view. Everything still compiles and runs fine there is just limited intellisense and tons of errors that get displayed when you open a view.

The one thing I noticed is that the HTML helpers are using a different Namespace than my other working project.

For instance if I hover over Html.BeginForm the Namespace shows WebPage.HTML. In a working project Html.BeginForm shows WebViewPage.

I have spent several hours going through all suggestions from older posts and nothing has worked yet.

Razor Views not seeing System.Web.Mvc.HtmlHelper

Why don't my Html Helpers have intellisense?

Because everything compiles and actually works I believe this problem is related to VS tooling or the /views/web.config. I have verified that the tooling is set to 14 in the .proj file and that all references are correct in the view/web.config but nothing has worked. Of course I have cleaned and rebuilt the solution more times that I can count. I have also completely installed mvc.net from nuget and reinstalled several times.

The only strange constraint in this project is that I can't upgrade it past mvc 4 because there are several other dependencies in the project that are tied to .net 4.

This is the relevant part of what my view/web.config looks like

<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
  <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
  <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
  <namespaces>
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Routing" />
  </namespaces>
</pages>
</system.web.webPages.razor>

<appSettings>
  <add key="webpages:Enabled" value="false" />
</appSettings>

This is the relevant sections from my web.config

 <appSettings>
<add key="webpages:Version" value="1.0.0.0"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
 </appSettings>
  <system.web>
<httpRuntime maxRequestLength="1048576" executionTimeout="1500"/>
<customErrors mode="RemoteOnly"></customErrors>
<compilation debug="true" targetFramework="4.0">

  <assemblies>
    <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  </assemblies>
</compilation>

Where do I go from here?

Community
  • 1
  • 1
intrex
  • 21
  • 3

1 Answers1

1

I finally figured this out and thought I would post this in case someone else runs into this nightmare.

This is a very old project that has been upgraded through many versions of Visual Studio and .net. It has a _bin_deployableAssemblies with very old MVC dlls. This was a VS 2010 construct. Even through I had upgraded MVC successfully through Nuget these old dlls were being used as the dll references.

To fix this I unloaded the project and manually removed lines that included the _bin_deployableAssemblies folder from the project. After doing that my references showed the proper versions numbers for the version of MVC that I installed multiple times from Nuget.

All that was then left to do was to do was to go through the web.config files and manually change the versions of all referenced dlls to the proper newer versions.

After a clean and rebuild everything is back to normal.

intrex
  • 21
  • 3
  • Hey Tim, I didn't realize I could accept my own anwser :). I just tried and it said I needed to wait 2 days before accepting. I will try to remember to come back and do that in a few days. – intrex Mar 11 '17 at 22:45