Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc VisualStudio没有';在我的Asp.net MVC视图中不显示Linq扩展_Asp.net Mvc_Visual Studio 2010_Configuration_Linq Extensions - Fatal编程技术网

Asp.net mvc VisualStudio没有';在我的Asp.net MVC视图中不显示Linq扩展

Asp.net mvc VisualStudio没有';在我的Asp.net MVC视图中不显示Linq扩展,asp.net-mvc,visual-studio-2010,configuration,linq-extensions,Asp.net Mvc,Visual Studio 2010,Configuration,Linq Extensions,这让我感到困惑,我似乎无法让VisualStudio2010在视图代码中识别System.Linq扩展方法。Intellisense不起作用,Visual Studio红色在无法识别的扩展方法下面加下划线 这些是web.config最相关的部分,我认为它们与VisualStudio相关,可以识别System.Linq扩展方法。注释掉的行可能没有注释,但没有区别 <compilation debug="true" batch="true"> <assemblies>

这让我感到困惑,我似乎无法让VisualStudio2010在视图代码中识别System.Linq扩展方法。Intellisense不起作用,Visual Studio红色在无法识别的扩展方法下面加下划线

这些是web.config最相关的部分,我认为它们与VisualStudio相关,可以识别System.Linq扩展方法。注释掉的行可能没有注释,但没有区别

<compilation debug="true" batch="true">
    <assemblies>
        <!--
        <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        -->
        <add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </assemblies>
</compilation>

<pages enableViewState="false">
    <namespaces>
        <add namespace="System.Collections.Generic"/>
        <add namespace="System.Linq"/>
        <add namespace="System.Web.Mvc"/>
        <add namespace="System.Web.Mvc.Html"/>
        <add namespace="System.Web.Routing"/>
        <add namespace="MyApp.Objects"/>
        <add namespace="MyApp.Web.General"/>
        <add namespace="MyApp.Web.Helpers"/>
    </namespaces>
</pages>

我有一个局部视图定义,如下所示。同样的,注释掉了两行。未注释没有区别:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IList<ToolbarItem>>" %>
<%--
<%@ Assembly Name="System.Core" %>
<%@ Import Namespace="System.Linq" %>
--%>
<%
    if (!this.Model.Any(ti => ti is ToolbarText && (ti as ToolbarText).MaximizeWidth))
    {
        this.Model.Add(new ToolbarText { MaximizeWidth = true });
    }
%>

ti是ToolbarText&(ti作为ToolbarText)。最大化宽度)
{
this.Model.Add(新工具栏文本{maximeWidth=true});
}
%>
在此特定的局部视图中,
Any()
扩展方法无法识别,即使它是在
System.Linq
命名空间下的
System.Core
程序集中定义的

我缺少哪些配置设置?Visual Studio似乎无法查看
System.Core
程序集来枚举
System.Linq
命名空间中的扩展方法。

可以尝试

<%@ Import Namespace="*" %>

其中*是要使用的名称空间,例如System.Linq


可能不是最好的方法,但它可能会工作(不是在使用vs so cant test的计算机上)

您需要将targetFramework的属性添加到web.config中的编译元素中:

<system.web>
    <compilation debug="true" targetFramework="4.0">


将其添加到web.config中,您应该在视图中重新获得intellisense。

当然
System.Core
程序集必须包含在配置编译中

但是当我清理我的
web.config
文件时,我删除了这个部分,这对于VisualStudio2010来说(显然)是必要的,以使事情按预期工作

<system.codedom>
    <compilers>
        <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
            <providerOption name="CompilerVersion" value="v3.5"/>
            <providerOption name="WarnAsError" value="false"/>
        </compiler>
    </compilers>
</system.codedom>


这是什么类型的。型号?@Jackson:开玩笑?你可以在定义中看到。。。它的类型是
IList
。不是开玩笑-不习惯ASP.Net-MVC/ASP.Net。不。。。已经试过了。。。还有
。。。没有区别。我将更新我的问题,指出我也尝试过。添加此属性可以使编辑器中的事情变得更好。但问题是我的目标是3.5。因此,我得到运行时错误,该属性无法识别。