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.
version v2.0.50727
does not natively supports Linq
. To solve your issue, you can try these two methods:
- Remove reference to
Linq
if possible (as already suggested by SS Kain). If removing
Linq
is not desirable for you, use the higher version. Instead of using csc fromC:\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 usingcsc.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\
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
Linq is not part of the .NET Framework 2, which you are using. Try a newer version instead.
Looks like you should remove
using System.Linq;
from the top of the file play.cs, since this reference is not available in .Net 2.0, which you are using.
I had a reference to System.Xml.Linq and still got an error.
The solution for me was:
- Swap .net ver to 2.0
- Rebuild (fails)
- Swap .net ver to 3.5(in my case),
- Rebuild (works).
精彩评论