Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The type or namespace name 'Linq' does not exist in the namespace 'System'

Tags:

.net

asp.net

wcf

I have a wcf service hosted in a website in IIS and I seem to have this issue. In my web.config I have this:

<system.web>
        <compilation>
            <assemblies>
                <add assembly="System.Core, 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="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add assembly="System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies>
        </compilation>
    </system.web>

All projects in the solution target framework 4.0.

LE: I get the error when I try to import System.Linq;

 using System.Linq;
like image 529
gigi Avatar asked Jan 30 '12 20:01

gigi


3 Answers

Solution: It seems that the web config should be:

<system.web>
    <compilation debug="true" targetFramework="4.0"/>
</system.web>
like image 53
gigi Avatar answered Nov 01 '22 17:11

gigi


Do you have a code file in your site with either Imports System.Linq (VB) or using System.Linq; (c#)?

Seems like the simplest answer is that it is a typo. Maybe the namespace should be corrected to System.Data.Linq.

Edit: System.Linq should be a valid namespace, as it "provides classes and interfaces that support queries that use Language-Integrated Query (LINQ)." (http://msdn.microsoft.com/en-us/library/system.linq.aspx). It is also imported by default in the system-level web.config.

So, not sure what is happening here if it is not related to my suggestion above. Maybe something wrong in your machine.config or system-level web.config?

Edit 2: I find it strange that you adding the System.Core assembly at this level. I believe this is the assembly that includes the System.Linq namespace. Maybe removing it would help?

Edit 3: System.Linq is imported by default in the machine-level web.config. You can remove the line in your code file.

like image 31
pseudocoder Avatar answered Nov 01 '22 18:11

pseudocoder


Sometimes it "disappears" just for the fun of it. If you don't need it just delete it.

Else right click your website in the solution explorer and add a reference to it.

like image 30
f2lollpll Avatar answered Nov 01 '22 18:11

f2lollpll