简体   繁体   中英

Visual Studio 2012 loses intellisense in MVC 4 Razor views

I'm developing a project with plug in ASP.MVC architecture. We use one main web application project and multiple subprojects. My problem is following - Visual Studio loses intellisense in MVC views in a subproject. On one developer machine it works while on another it doesn't. I know we need some NuGet packages to be installed, I know we need Web.config in Views directory. It's all configured and still after moving into another developer machine it stops working.

I've tried:

  • IIS reset
  • Visual Studio reset
  • Running visual studio with elevated privileges
  • PC reboot
  • Creating new web project
  • Deleting suo file
  • Deleting csproj.user file
  • Installing ASP.NET and Web Tools 2013.1 for Visual Studio 2012
  • Reseting VS environment settings

And still when I run project in other developer machine it doesn't support intellisense in my subproject.

I had the same issues. When codebase is large, intellisense can be lost.

Some of developers in our team were struggling with that for a long time. But installed Resharper . It always worked fine for us after that.

I think you have to wait for a patch, or install try to install Resharper, it's free for 30 days.

Finally I've found a solution. I've modified Web.config of subproject and added following code to it:

<compilation debug="true" targetFramework="4.5">
      <!-- New -->
      <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=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </assemblies>
    </compilation>

I also changed web subproject properties, on the Web tab I unchecked "Apply server settings to all users (store in project file)".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM