Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The type or namespace name 'Linq' does not exist

While fiddling with Naudio, I found this code. I am compiling it as:

csc.exe /reference:Naudio.dll play.cs

and getting the error:

play.cs(3,14): error CS0234: The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?)

The version of csc is: C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.EXE

While searching for it, I found a thread which says I need to add System.core reference, but doing something like: /reference:System.core.dll or /reference:System.core is not solving the problem.

like image 394
John Smith Avatar asked Jul 20 '11 10:07

John Smith


2 Answers

version v2.0.50727 does not natively supports Linq. To solve your issue, you can try these two methods:

  1. Remove reference to Linq if possible (as already suggested by SS Kain).
  2. If removing Linq is not desirable for you, use the higher version. Instead of using csc from C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.EXE, I would suggest upgrading to the latest .NET version (provided your deployment doesn't have issues with that) and try using csc.exe from there.

    I use C:\Windows\Microsoft.NET\Framework\v4.0.30319\ and that works fine for me.

    Also note that if you are using Visual Studio 2010 command prompt, this path is not added by default to your PATH env variable and so you will have to add it manually.

    set PATH=%PATH%;C:\Windows\Microsoft.NET\Framework\v4.0.30319\

like image 64
Vikram.exe Avatar answered Sep 28 '22 14:09

Vikram.exe


I believe that 2.0.50727 does not support Linq, remove Linq from references and from "usings" and hope that there are no Linq statements in the code

like image 28
Djole Avatar answered Sep 28 '22 14:09

Djole