Razor Intellisense 无法工作 WPI Win7 x64 中的 VS2010 SP1Rel MVC3

发布于 2024-11-09 15:15:38 字数 1258 浏览 2 评论 0原文

我在全新安装了 Windows 7 64 位专业版的计算机上安装了 Visual Studio 2010 /SP1 / MVC 3(带有四月工具更新)。

我没有安装 resharper。 我从未在这个新操作系统安装上安装过任何 RC 或 Beta 版本。

我的安装步骤如下:

  1. 安装 Visual Studio Professional。
  2. 安装 Web 平台安装程序。
  3. 从 WPI 安装 Visual Studio SP1。
  4. 安装 Microsoft ASP.net MVC 3(带有四月工具更新)
  5. 安装 Productivity Power Tools

帮助 >关于 Microsoft Visual Studio 显示:

Microsoft Visual Studio 2010 版本 10.0.40219.1 SP1Rel

Microsoft .NET Framework 版本 4.0.30319 SP1Rel

System.Web.Mvc.dll 文件版本显示:3.0.20105.0

安装后,我执行了以下操作:

  1. 打开 Visual Studio。
  2. 文件>新建项目
  3. 选择“ASP.Net MVC 3 Web 应用程序”。
  4. 在“新建 ASP.NET MVC 3 项目”对话框中。我选择了“互联网应用程序”、“Razor”视图引擎。点击“确定”。

在项目中,行为如下:

  1. 打开任何 cshtml 文件,Razor @blocks 不会突出显示。
  2. Intellisense 将 html 片段作为 razor 块内外的选项提供,但无法识别其中的 Html 帮助程序或模型等。
  3. 项目构建。
  4. 您可以运行该项目,构建后一切正常。 Razor 视图正常渲染。

有谁知道 Razor Intellisense 工作的一组明确的先决条件吗?我可以区分其他运行 Razor Intellisense 的 Win7 64 位计算机和有此问题的 2 台计算机吗?注册表项?是否有任何 Visual Studio 日志可以帮助调试此问题?经过几个小时的沮丧和阅读我遇到的每一篇 Razor Intellisense 帖子和问题,但没有提出任何有效的方法,我只是希望对下一步要排除故障/尝试的内容有一些新的想法。

感谢您对此的任何帮助。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

平定天下 2024-11-16 15:15:38

我知道距离上一篇文章已经有一段时间了,但我通过卸载 MVC 2 和 MVC2 VS Tools 并只保留安装的 MVC 3 来修复我的问题。

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.

蓝海 2024-11-16 15:15:38

如果您安装了 MVC4 和 MVC3,则需要将其添加到 web.config 中的 appsettings(在 root 和 Views 文件夹中)才能使用 MVC3

<appsettings>
    <add key="webpages:Version" value="1.0.0.0">
    ...
</appsettings>

另请检查 root web.config 中的引用,它们应该包含这些版本

<add assembly="System.Web.Helpers, Version=1.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.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

重新打开您的解决方案设置生效

If you have MVC4 and MVC3 installed you need to add this to appsettings in web.config (in root and in Views folder) to use MVC3

<appsettings>
    <add key="webpages:Version" value="1.0.0.0">
    ...
</appsettings>

Also check your references in root web.config, they should included these versions

<add assembly="System.Web.Helpers, Version=1.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.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

Re-open your solution for settings to take effect

書生途 2024-11-16 15:15:38

我只是在这上面浪费了我生命中的两个小时。我遇到的情况是 web.config 文件签入错误,并且不再是 Unicode UTF8。当VS 2010打开解决方案时,它会检查web.config文件中的appsettings:

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

由于该文件无法通过正常方式读取,因此它完全跳过它,导致VS认为您需要重新安装MVC...我只是想要发布此内容,以防其他人遇到同样的问题以便轻松解决。

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.

一场春暖 2024-11-16 15:15:38

Razor Intellisense 与 Razor Editor 配合使用,

检查它是否被选为默认编辑器,为此,请

  • 右键单击视图文件 (.cshtml)
  • 选择打开方式...
  • 检查 Razor 编辑器
  • 如果没有选择为默认编辑器,则卸载mvc3 从控制面板重新安装它。

再次检查文件必须在 Razor 编辑器中打开。我已经做到了这一点并且现在可以工作了。

Razor Intellisense work with Razor Editor

Check if it is selected as default editor, For this do

  • Right Click on view file (.cshtml)
  • Select Open With...
  • Check Razor editor Select as default
  • if not, uninstall mvc3 from control panel reinstall it.

Again check files must be opened in Razor Editor. I have done this and its working now.

⊕婉儿 2024-11-16 15:15:38

我通过右键单击 cshtml 文件并选择“查看标记”来修复它。

I fixed it by right clicking on the cshtml file and selecting "View Markup".

顾冷 2024-11-16 15:15:38

您可能已经尝试过这一方法,但对我来说,这篇博文中的步骤有效: http://blogs.msdn.com/b/webdevtools/archive/2011/03/24/razor-tooling-for-mvc3-rc-with-visual-studio-2010-sp1-rtm。 ASPX

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

北方。的韩爷 2024-11-16 15:15:38

我们遇到了问题,因为编译器在构建 Razor 视图时似乎使用 32 位 MSBuild,即使您将所有项目设置为 64 位或任何 Cpu。当我们强制将 Web 项目强制为 64 位时,它无法编译,因为 razor 视图是在 32 位中构建的,并且由于某些视图引用了引用了第三方 64 位 dll 的项目而失败。

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.

心意如水 2024-11-16 15:15:38

我的一个项目遇到了这个问题,问题是当我将其从独立的 MVC 应用程序转换为 Orchard 模块时,该项目以某种方式转换为类库项目。

通过在文本编辑器中打开 .csproj 文件并将此行: 替换

<ProjectTypeGuids>{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>

为以下内容来修复:

<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>

I had this problem with one of my projects and the problem was the project somehow got converted to a Class Library project when I converted it from a standalone MVC app into an Orchard module.

Fixed by opening the .csproj file in a text editor and replacing this line:

<ProjectTypeGuids>{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>

with this:

<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
扛刀软妹 2024-11-16 15:15:38

请注意,对我来说,导致问题的是安装的 Roslyn 语言服务插件。当我卸载插件后,问题就解决了。要卸载插件,只需转到工具->扩展管理器并找到插件 Roslyn Language Services。单击卸载按钮并重新启动VS2010。

Please note that for me what caused the problem was the Roslyn Language Services plugin installed. When I uninstalled the plugin the issue was solved. To uninstall the plugin simply go to tools->extension manager and find the plugin Roslyn Language Services. Click the uninstall button and restart VS2010.

荒岛晴空 2024-11-16 15:15:38

我遇到了同样的问题,我只需安装 Visual studio 2010 SP1 即可解决它。从那时起一切都运转良好。我希望这对你有帮助。

您可以从这里下载:
http://www.microsoft.com/download/en/details.aspx ?id=23691

祝你好运

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

暖伴 2024-11-16 15:15:38

就像提到的 BuildStarter 一样,单击“打开方式”并将默认值设置为 Razor 编辑器,即使它已经设置。应该获得颜色编码和智能感知。

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.

百变从容 2024-11-16 15:15:38

我遇到了同样的问题。当我将视图 web.config 中的视图引擎更改为自定义引擎时,它开始随机发生。这是一个已知问题,当自定义视图引擎到位或视图继承自自定义视图页面时,VS2010 Intellisense 在识别保留字方面存在问题。

每个遇到 Razor Intellisense 问题的人都应该检查一下。上述修复(重新安装 VS、重新应用 SP1、重新应用 MVC3 工具更新)都没有帮助。

I was experiencing the same issue. It started to happen randomly when I changed the view engine in the Views web.config to a custom one. It is a known problem VS2010 Intellisense has issues with recognizing reserved words when custom view engine is in place or when a view inherits from a custom view page.

Everyone running into Razor Intellisense issues should check this out. None of the above fixes (reinstalling VS, rapplying SP1, reapplying MVC3 Tools Update) did help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文