Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

visual studio 2010 - The type or namespace name 'Linq' does not exist in the namespace 'System.Data' , etc

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

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

  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.

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.

Some technical details:

  • 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.

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"/>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

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.

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...