Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

Image

like image 474
javad Avatar asked Jun 08 '16 06:06

javad


3 Answers

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)

  1. 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.)
  2. Change the Target Framework from .Net Framework 4 to .Net Framework 3.5
  3. Confirm with OK
  4. Repeat this process in reverse so, again hit Shift+F4
  5. Change it back from .Net Framework 3.5 to .Net Framework 4

Hope this helps

like image 83
DevCentral Avatar answered Nov 06 '22 09:11

DevCentral


Try to Unload and then reload the concerned project. That will do it.

like image 29
minchiya Avatar answered Nov 06 '22 09:11

minchiya


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>
like image 4
Hamed Avatar answered Nov 06 '22 11:11

Hamed