MVC 3 Visual Studio 2010 Razor Model intellisense

2019-07-25 00:12发布

问题:

Ever since I updated my projects for VS 11 I can't get my @Model intellisense to work in either version of Visual Studio (2010 or 11). I've tried reverting the .csproj file to remove the VS 11 references, but to no avail. Other MVC 3 Razor project are working just fine. Anyone experience this?

回答1:

Not working in both versions of Visual Studio smells like the install is possibly corrupted a bit. My first step would be to try and repair the Visual Studio 2010 install and see if the Intellisense behavior comes back for 2010 only.

  • Control Panel
  • Add / Remove Programs
  • Visual Studio 2010
  • Select Repair in the menu

If this works then you could be happy with the returned intellisense or try the same steps for Visual Studio 11 and hope it fixes it for both. But if the installation of 2011 is to blame then very likely it would just immediately rebreak both of them



回答2:

I found this article that addressed my issue.

EDIT:

It seems that some combination of installing VS 11 and some tool updates caused this issue. I got luck and managed to get the following error message:

The type System.Web.Mvc.ModelClientValidationRule exists in both c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v2.O\Assemblies\System.Web.WebPages.dll and c:\Program
Files (6)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll

After doing some digging I wound up uninstalling "Microsoft ASP.NET Web Pages 2 - Visual Studio 2010 Tools", which resulted in everything working. Granted it may have been a better idea to uninstall "Microsoft ASP.NET Web Pages - Visual Studio 2010 Tools" instead, but this is working at the moment.

I found a complete lack of information on the Internet about this type of issue, so I'm putting it here for posterity.