The type or namespace name 'Linq' does not exist in the namespace 'System'
Solution 1
I had an issue with System.Linq not being recognized. The way I solved it was to change the targeted framework of my website from 4.0 to to 3.5 and then switch back to the original targeted framework (in my case 4.0)
- Hit Shift+F4 or right click at the project level and select Property Pages in Visual Studio. (Alt+Enter or right click at the project level and select Properties in VS2017.)
- Change the Target Framework from .Net Framework 4 to .Net Framework 3.5
- Confirm with OK
- Repeat this process in reverse so, again hit Shift+F4
- Change it back from .Net Framework 3.5 to .Net Framework 4
Hope this helps
Solution 2
Try to Unload and then reload the concerned project. That will do it.
Solution 3
Put this piece of code in the Configuration file (Web.config) and test it.
<compilation debug="false">
<assemblies>
<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"/>
<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"/>
</assemblies>
</compilation>
Solution 4
Visual Studio 2015 References -> Add Reference -> Assemblies -> select System.Data.Linq
Solution 5
Try this one. Maybe targetFramework="4.0" will work. Worked for me.
<compilation debug="false" targetFramework="4.0">
<assemblies>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
Related videos on Youtube
javad
Updated on September 05, 2020Comments
-
javad almost 4 years
When I want to use button to write code in C# it doesn't go to the ".cs" file to write C# code. When I check the project source, I found this error:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls;
Severity Code Description Project File Line Error CS0234 The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?) Golestani C:\Users\javad\Documents\Golestani\Login.aspx.cs 3
-
javad about 8 yearsWhat Do You Mean??
-
Hamed about 8 yearsRight click your project -> Add Reference -> select Framework tab -> select System.Core
-
AmirHossein Rezaei almost 6 yearsGo to project -> References -> Add Reference -> -> Assemblies -> Search for "System.Xml.Linq" and check it.
-
-
Malcolm Anderson about 7 yearsIf Shift+F4 doesn't work, just right click at the project level and select "Property Pages"
-
EricImhauser over 5 yearsThat did work for me after hours of research. Thanks
-
user2163234 over 5 yearsVS is nice when it works, but its some ungodly Frankenstein collection of stuff and things go to hell frequently and are a nightmare figure out. It's frustrating when you decide to reinstall windows just to get VS to work again. Teach me to try to use it for R and Python and still expect C# to work too.
-
Aron Boyette over 5 yearsI had success with this change, although I only needed to do System.Core. And for those who haven't memorized the the Web.config XML schema, the <compilation> element goes under <system.web>. @Hamed, I urge you to change your answer to include <system.web> and to fix the syntax highlighting.
-
blind Skwirl almost 5 yearsyup, just closing and reopening VS2017 did it for me. Happens often for various issues.
-
yu yang Jian over 4 yearsThis action may change the content of web.config, suggest to check what content is modify after change, to ensure that no function is thus disabled.
-
Marco Aurelio Fernandez Reyes about 3 yearsIn my case (changing from Framework 2.0 to Framework 3.5) fixed the problem. Thank you.
-
Rajesh Thampi over 2 yearsWorked on Windows 2008 R2 for an age old intranet website. Thank you.
-
wallef over 2 yearsThis worked for me in VS 2022