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.
- The type or namespace name 'Linq' does not exist in the namespace 'System.Data'
- 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=31BF3856A开发者_JAVA技巧D364E35"/>
<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>
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.)
I've been having the same problem on exactly the same config except for my Windows 7 is 64-bit. Got it solved by doing [project name] -> References -> Add reference -> System.Data.Linq
Why do you add references by hand?
Important, you must set in webconfig
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
You can try following:
Add reference to System.Data.Linq (Right click on References folder | Select Add Reference | Select .Net tab(Is default selected) | select System.Data.Linq reference | click OK.
I hope this will help you or someone else.
精彩评论