Razor Intellisense Not Working VS2010 SP1Rel MVC3

2019-01-18 21:27发布

I have Visual Studio 2010 /SP1 / MVC 3 (With April Tools Update) installed on a machine with a fresh install of Windows 7 64-bit Professional.

I do not have resharper installed. I never installed an RC or Beta of anything on this new OS Install.

My install steps were as follows:

  1. Install Visual Studio Professional.
  2. Install Web Platform Installer.
  3. Install Visual Studio SP1 from WPI.
  4. Install Microsoft ASP.net MVC 3 (with April Tools Update)
  5. Install Productivity Power Tools

Help > About Microsoft Visual Studio shows:

Microsoft Visual Studio 2010 Version 10.0.40219.1 SP1Rel

Microsoft .NET Framework Version 4.0.30319 SP1Rel

System.Web.Mvc.dll file version shows: 3.0.20105.0

Once installed I did the following:

  1. Open Visual Studio.
  2. File > New Project
  3. Choose "ASP.Net MVC 3 Web Application".
  4. On the "New ASP.NET MVC 3 Project" dialog. I chose "Internet Application", "Razor" View Engine. Hit OK.

Within the project here is the behavior:

  1. Open any cshtml file and Razor @blocks are not highlighted.
  2. Intellisense gives html snippets as options in and outside of razor blocks but does not recognize Html helpers or models etc within them.
  3. The project builds.
  4. You can run the project and everything works when built. Razor views are rendered normally.

Does anyone know a definitive set of prerequisites to have Razor Intellisense working? Something I can diff between the other Win7 64-bit machines that have Razor Intellisense working and the 2 that have this issue? Registry entries? Are there any Visual Studio logs that can help debug this? After hours of frustration and reading every Razor Intellisense post and question I have run across without coming up with anything that works I am just hoping for some new thoughts on what to troubleshoot/try next.

Thanks for any help on this.

12条回答
霸刀☆藐视天下
2楼-- · 2019-01-18 22:20

We ran into issues because it appears the compiler uses the 32-bit MSBuild when building the Razor views, even if you have all of your projects set to 64-bit or Any Cpu. Our web project would not compile when we forced it to 64-bit because the razor views were being built in 32-bit and failing because some of the views were referencing a project that had a 3rd party 64-bit dll referenced.

查看更多
仙女界的扛把子
3楼-- · 2019-01-18 22:21

I just wasted 2 hours of my life on this. What happened to me is that the web.config file got checked in wrong and was no longer Unicode UTF8. When VS 2010 opened the solution, it checks the web.config file for the appsettings:

<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="true" />

Since the file couldn't be read by normal means, it just skipped it entirely, causing VS to think you needed to reinstall MVC... I just wanted to post this in case someone else runs into the same problem for an easy fix.

查看更多
Fickle 薄情
4楼-- · 2019-01-18 22:23

You probably have already tried that one, but for me the steps in this blog-post worked: http://blogs.msdn.com/b/webdevtools/archive/2011/03/24/razor-tooling-for-mvc3-rc-with-visual-studio-2010-sp1-rtm.aspx

查看更多
Evening l夕情丶
5楼-- · 2019-01-18 22:25

Like BuildStarter mentionned, Click Open With and set the default to Razor Editor even if it's already set. Should get the color coding and intelisense.

查看更多
三岁会撩人
6楼-- · 2019-01-18 22:27

I had the same problem, I fixed it simply by installing Visual studio 2010 SP1. Everything is working fine since then. I hope this helps you.

You can download it from here: http://www.microsoft.com/download/en/details.aspx?id=23691

Good luck

查看更多
Viruses.
7楼-- · 2019-01-18 22:29

I know it's been a while since the last post, but I fixed mine by uninstalling MVC 2 and MVC2 VS Tools, and only leaving MVC 3 installed.

查看更多
登录 后发表回答