类型或名称空间名称'Linq'在名称空间'System.Data'等中不存在 [英] The type or namespace name 'Linq' does not exist in the namespace 'System.Data' , etc

查看:100
本文介绍了类型或名称空间名称'Linq'在名称空间'System.Data'等中不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在Visual Studio 2010中制作了一个Linq-to-SQL .dbml文件.

I just made a Linq-to-SQL .dbml file in Visual Studio 2010.

我遇到以下2个错误,总共60次,大部分是第一次.

I'm getting the following 2 errors, a total of 60 times in total, mostly the first.

  1. 类型或名称空间名称"Linq" 名称空间"System.Data"中不存在
  2. 类型或名称空间 找不到名称"EntitySet"
  1. The type or namespace name 'Linq' does not exist in the namespace 'System.Data'
  2. The type or namespace name 'EntitySet' could not be found

我在这里和其他站点上发现了各种类似的问题,所有这些似乎都表明需要添加一些额外的程序集.

I've found various similar questions here and on other sites, all of which seem to say that some extra assembly needs to be added.

我添加了每个建议,问题仍然存在.另一个奇怪的是,VS2010本身并没有在编辑器屏幕上突出显示错误,而是在错误日志中显示了错误.

I've added every one suggested, the problem persists. Another odd thing is that VS2010 itself doesn't underline the errors in the editor screen, but it does show them in the error log.

无论如何,我已经看过所有现有主题并应用了它们的解决方案,问题仍然存在.

Anyways, I've seen all the existing topics and applied their solutions, the problem persists.

一些技术细节:

  • 我正在运行32位Windows 7.
  • 我仍然有Visual Studio 2008 SP1 已安装.我刚安装VS2010 当它出来,并没有删除 较老的.
  • 我正在运行MSSQL Server 2008 R2.
  • I'm running Windows 7 32-bit.
  • I still have Visual Studio 2008 SP1 installed. I just installed VS2010 when it came out and didn't remove the older one.
  • I'm running MSSQL server 2008 R2.

这是我的web.config文件中列出的程序集:

And here's the assemblies listed in my web.config file:

<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Services.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Services.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.SqlXml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

推荐答案

我发现

I found this link which solved it for me. The net is that the following must be added to web.config:

<configuration>
  <system.web>
     <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
      </assemblies>
    </compilation>
   </system.web>
</configuration>

请注意,configuration/system.web/compilation标签已经存在,并且需要添加assembly/add组件标签.即使System.Data.Linq在构建时很容易被VS找到.

Note that the configuration/system.web/compilation tags are already there, and the assemblies/add assembly tags need to be added. This even though System.Data.Linq is readily found by VS when building.

失败是在App_Code.LinqToObservations.designer.cs中,这是Linq从我的LinqToObservations.dbml文件生成的代码.

The failure was in App_Code.LinqToObservations.designer.cs, code that's generated by Linq from my LinqToObservations.dbml file.

(其他背景:我很可能会遇到这种情况,因为在使用此处中找到的过程之后,我启用了Linq. )

(Additional background: I likely got into this situation because I enabled Linq after the fact using the procedure found here.)

这篇关于类型或名称空间名称'Linq'在名称空间'System.Data'等中不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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