C# – can’t add System.Linq reference to website application

asp.netc++iis

I can't seem to fingure out why i can't add a reference to the .net namespace System.Linq. I used aspnet_regiis to check if i have the latest version of asp.net installed :

    C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis -lv
    2.0.50727.0    C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll
    4.0.30319.0    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll
    4.0.30319.0    C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll

I've also tried adding a reference to System.Core, but still i can't reference the System.Linq dll.

Also in my web.config, under

      <assemblies>
           <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
      </assemblies>     

as iv'e mentioned before the refrences to System.Core and System.Data.Linq Exist in my website application : under Property Page -> references i could clearly see the exsiting refrences i added them again just in case and still i can't use the
System.Linq or System.Linq.Data NameSpaces .

Any ideas how i could reference the System.Linq dll would be appreciated.

Best Solution

System.Core is the dll that the System.Linq namespace is in. As long as you have a reference to System.Core in your project you should be able to do

using System.Linq;

in any source file in whcih you want to use the Linq methods.

Check under References in the Solution Explorer. If System.Core is not there then:

  • Right-click References
  • Click "Add Reference..."
  • Choose System.Core from the .Net tab