升级到4.0:命名空间“System”中不存在类型或命名空间名称“Linq”(您是否缺少程序集引用?)

我最近将我的解决方案从.net framework 3.5升级到4.0.一切都很好,除了它在我的网站项目中给我一些错误.

The type or namespace name 'Linq' does not exist in the namespace 'System' 
(are you missing an assembly reference?)

The type or namespace name 'Linq' does not exist in the namespace 'System.Xml'
(are you missing an assembly reference?)

The type or namespace name 'Script' does not exist in the namespace 'System.Web' 
(are you missing an assembly reference?)

这是我的web.config看起来像:

<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<!--vjslib is needed for Google Transit-related code-->
<add assembly="vjslib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="Infragistics35.WebUI.Shared.v10.2, Version=10.2.20102.1011, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"/>
<add assembly="Infragistics35.WebUI.UltraWebGrid.v10.2, Version=10.2.20102.1011, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"/>
<add assembly="Infragistics35.WebUI.UltraWebTab.v10.2, Version=10.2.20102.1011, Culture=neutral, PublicKeyToken=7DD5C3163F2CD0CB"/>
<add assembly="Infragistics35.Web.v10.2, Version=10.2.20102.1011, Culture=neutral, PublicKeyToken=7DD5C3163F2CD0CB"/>
<add assembly="System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add assembly="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

当我说使用System.Linq或System.Xml.Linq时,为什么它找不到LINQ引用?我在这里失踪了什么?

– 编辑 –

这只发生在网站项目中.其他类库工作正常.

最佳答案
我有一个ASP.NET 3.5 WebSite项目,我试图升级到.NET v4.得到了错误.
我的解决方案

>转到WebSite项目属性页并将其重新设置为. NET v3.5
>编译并查看一切正常
>将其切换回.NET v4
>编译并查看一切正常

转载注明原文:升级到4.0:命名空间“System”中不存在类型或命名空间名称“Linq”(您是否缺少程序集引用?) - 代码日志