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

  • Question

  • User-991753956 posted

     Hi everybody,

    I have a Web app project that uses Linq. I am receiving the following error:

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

    in the line:

    using System.Data.Linq;

    The reference points to the correct file and in other projects everything is fine. the projects builds successfully and gives this error right after that.

    If someone has an idea what is happening or some previous experience with such an error - please.

    Thank you in advance.
     

    Thursday, May 22, 2008 6:46 AM

Answers

  • User1597794569 posted

    Hi,

    I hope that you fixed the problem, just in case you did not add this line into web config where other assembly's are

    <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 26, 2008 1:30 PM

All replies

  • User-1853252149 posted

    Did you install Linq on the server?

    Jeff

    Thursday, May 22, 2008 7:18 AM
  • User-991753956 posted

    I am testing it on my local machine - I have VS2008 installed - I think it should be ok and besides I have other apps that are working with linq. Do you think I have to install Linq separately?

    Zhivko 

    Thursday, May 22, 2008 8:02 AM
  • User1997439278 posted

     Joppo
     

    It is something related with your web.config file I think.  I also have a project and trying to get AJAX working.  So I have two different web.config files and I make trials with both of them.  When I run the application with one of the web.config files it works.  However with the other one it gives the error

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

    I could not figure it out right now but it seems that it is related with some missing entries in the web.config file.   If I solve it I will post....

    Sunday, May 25, 2008 2:05 AM
  • User1997439278 posted

     I resolved the problem.

     

    I copied the compilation section under the <system.web> tag from the working web.config.  That is:

     

    <compilation debug="true">
                <assemblies>
                    <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                    <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
                    <add assembly="System.Data.DataSetExtensions, 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.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                    <add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                    <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                    <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                    <add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
          </assemblies>
            </compilation>

     Be careful that the crucial lines here are:

     <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"/>

    to resolve the System.Linq.... error.  The others are  related with my particular application.  But I posted them in any case....

     
    After this, another error has occurred.   It said:
     

    "'System.Array' does not contain a definition for Contains"  ..................

     Then I also copied the <system.codedom> tag which is a child tag of <configuration>

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

     

    And finally it worked...

    Sunday, May 25, 2008 3:21 AM
  • User1597794569 posted

    Hi,

    I hope that you fixed the problem, just in case you did not add this line into web config where other assembly's are

    <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 26, 2008 1:30 PM
  • User1827812781 posted

    According to another post on the issue at http://msdn.microsoft.com/en-us/library/system.linq.aspx, they suggest adding a reference to System.Core (v3.5) --in Visual Studio ( "Website" menu | "Add Reference..." | ".NET" tab | Component Name "System.Core".  That fixed it for me.  Not sure which is more appropriate...anyone?  Thanks, Mike.

    Monday, February 16, 2009 4:09 PM
  • User-1081600188 posted

     gr9 thanks, this solution worked for me. i was facing error mentioned in subject and adding this line worked.

    Thanks!

    Wednesday, March 11, 2009 11:13 PM
  • User-2085590579 posted

    Really great solution putting this in the web.config file. Worked like a charm!

    Thanks!

    Wednesday, May 13, 2009 7:56 AM
  • User-1292136282 posted

    Melliott,

    I added the "System.Core" reference as suggested on the msdn site. I even had the proper web.config assembly references in place as described within the previous forum posts above, but the error didn't go away until I added a Reference to "System.Data.Linq" to my project by clicking on the Project's Name in Visual Studio, then "add reference" then "System.Data.Linq" on the .Net tab then the OK button.

    Saturday, May 16, 2009 7:51 AM
  • User-700129311 posted

    Thanks, was stuck for a few minutes on the same thing


    Saturday, January 2, 2010 11:42 AM
  • User-1431905850 posted

    I'm having the same problem now...why?   The first thing you read when you open up a book on Visual C# 2008 and Linq is that there's nothing to install.   Linq is supposed to just be there.  I didn't have any luck with the fixes above; this is using VS2010 Beta 2.

    Sunday, January 17, 2010 12:08 AM
  • User-1832578474 posted

    I am ready to scream at this... Please help!


    I got this after I added another table to the "SQL to LINQ" dbml item.

    One table it was fine, working great, add second table and third table this stuff starts happening.



    This is my assembly:


    		<compilation debug="true">
    			<assemblies>
    				<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.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    				<add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    			</assemblies>
    		</compilation>




    Codedom:


    	<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>
    			<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
    				<providerOption name="CompilerVersion" value="v3.5"/>
    				<providerOption name="OptionInfer" value="true"/>
    				<providerOption name="WarnAsError" value="false"/></compiler></compilers></system.codedom>





    Tuesday, April 13, 2010 10:20 AM
  • User-1832578474 posted

    Figured it out, my Table name was "Systems"  which made it have the class "System" and System is of course a reserved word.....  Renames it to AllSystem and everything worked perfect   ....  what a waste of time

    Tuesday, April 13, 2010 10:51 AM