剃刀语法给出查看错误在编译之前(无智能感知) [英] Razor Syntax gives errors in View before compiling (No intellisense)

查看:300
本文介绍了剃刀语法给出查看错误在编译之前(无智能感知)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在经历的NuGet包的列表,我正在更新一切之类的东西引导,jQuery的,等等。但是当我这样做,我不假思索地更新的 Microsoft.Owin 并另一个包(可能已经EF或别的东西),这是一个主要版本更新... woops。

I was going through the list of NuGet Packages and I was updating everything things like bootstrap, jQuery, etc. but while I was doing that, I unthinkingly updated Microsoft.Owin and another package (might have been EF or something else) and it was a major version update...woops.

我赴汤蹈火删除我的项目,从源头控制得到一个旧版本,并让一切回到正确的版本。一切都恢复正常,我还有最后一个问题。 剃刀语法

I had to jump through hoops by deleting my project, getting an older version from source control and getting everything back to the right versions. Everything is back to normal and I have one last issue. Razor Syntax.

当我打开我的任何意见......在任何地方项目中,我得到这个:
< IMG SRC =htt​​p://i.stack.imgur.com/pX4S4.jpgALT =在这里输入的形象描述>

When I open up any of my views...anywhere in the project, I get this:

注意如何使用什么剃刀用红色标记错误抽搐。他们每说名称''不在目前情况下存在

Notice how anything using Razor is marked with red error squiggle. They each say "The name '' does not exist in the current context".

当我关闭文件,显示没有错误。此外,当我运行该项目,有没有问题,一切都运行完美。问题是,我没有IntelliSense和它不承认我的任何剃刀帮手。

When I close the file, no errors are shown. Also, when I run the project, there are no issues and everything works PERFECT. The problem is, I have no intellisense and it doesn't recognize any of my razor helpers.

下面是我的项目说明:

EntityFramework 6.0
Microsoft.Owin 2.1.0.0
Owin 1.0.0
System.Web.Mvc 5.2.2.0
System.Web.Razor 3.0.0.0

在我的包文件夹中我也有:

In my packages folder I also have:

Microsoft.AspNet.Mvc.5.2.2
Microsoft.AspNet.Razor.3.2.2
Microsoft.WebPages.3.2.2

我修改我的WebConfig修复多个错误,现在有如下的代码吧:

I've modified my WebConfig to fix multiple errors and it now has the following code in it:

<compilation debug="true" targetFramework="4.5.1">
      <assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Razor, 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.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </assemblies>
    </compilation>

和下:<运行>< assemblyBinding的xmlns =金塔:架构 - 微软-COM:asm.v1>

我有这些:

<dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.AspNet.Identity.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="3.0.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
      </dependentAssembly>

和在每个查看文件夹在我的项目,我有以下在的Web.Config 文件里的代码:; configSections>

And on each of the View folders in my project I have the following code inside of the Web.Config file:

<configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.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=5.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.Optimization"/>
        <add namespace="System.Web.Routing" />
        <add namespace="IcapOrg" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>



我曾尝试将其卸载,重新安装,升级,降级,删除和添加组件,和许多更多的事情我已经开始忘记。我真的不知道在哪里可以从这里移动。我可以保持编码,但它只是将是没有智能感知一个真正的痛苦。感谢您事先的任何帮助。

I have tried uninstalling it, re-installing, upgrading, downgrading, removing and adding assemblies, and many more things I've started to forget. I'm not really sure where to move on from here. I can keep coding but it's just going to be a real pain without intellisense. Thank you in advance for any help.

推荐答案

在搜索的时候,我终于找到了这个网页:的 MVC的Razor视图智能感知在VS 2013破

After days of searching, I finally found this page: MVC Razor view Intellisense broken in VS 2013

在我的意见>的Web.Config 文件中,我发现这个代码:

In my Views > Web.Config file I found this code:

 <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.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" />
        <add namespace="System.Web.Optimization" />
        <add namespace="System.Web.Helpers"/>
        <add namespace="IcapOrg" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>



其中,你可以看到,上有错误版本的MVC。我以前只检查< sectionGroup> 标签的正确版本的 RAZOR 但是我忽略了 MVC 也需要正确的版本。切换版本:

Which, as you can see, has the wrong version of MVC on it. I had previously only checking the <sectionGroup> tags for the proper version of RAZOR but I neglected the fact that MVC also needs the proper version. Switching the version to:

<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />



解决我的问题。这让我想起总是在我的代码看起来非常。仔细

Solved my problem. This reminds me to always look over my code VERY carefully.

请注意:如您在这个问题看,版本5.0.0说,这人说4.0.0。我在不同的查看文件夹不同的web.config文件中都有不同的版本写下来。非常怪异。

NOTE: As you can see in the question, the version says 5.0.0, and this one says 4.0.0. Different Web.Config files in my different view folders all had different versions written down. Extremely weird.

这篇关于剃刀语法给出查看错误在编译之前(无智能感知)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆