Reputation: 13739
Why might "using System.Linq" cause the following error?
The type or namespace name 'Linq' does not exist in the namespace 'System'
Upvotes: 10
Views: 29136
Reputation: 41
In my case the only thing that worked was:
The package that makes System.Linq
available to Razor Views IntelliSense seems to be Microsoft.AspNet.WebPages
.
Upvotes: 0
Reputation: 689
Manually type using System.Linq
in the starting of the project, you will not be able to find this namespace in add reference dialogue box.
If you are still getting error then try to Add Reference System.Core
.
If you are getting an error that it has been already referred then you can unload your project and then edit your csproject file, manually copy reference to System
tag and paste and change the name to System.Core
and reload the project.
Upvotes: 0
Reputation: 42363
Reference System.Core
And then there are others that merge this namespace too - but that's the primary one on .Net 3.5 and above.
If you're project is currently .Net 2.0, say, and you're using the right version of VS (2005 and above) - you can simply right-click on the proejct properties; and change the 'Target Framework Version' to 3.5. System.Core
will then become available.
If you don't see that in the options - then I guess you're using an older VS
Upvotes: 19
Reputation: 30875
You are using lower version of .NET Framework than 3.5 to compile the source code or you don't have added the System.Core assembly to your project.
Upvotes: 3
Reputation: 6503
You'll get this error if you don't have "System.Core.dll" referenced (the assembly which contains the core LINQ APIs).
Upvotes: 4
Reputation: 6482
Maybe you're targeting an older framework, Linq came in with 3.5 IIRC.
Upvotes: 3
Reputation: 364409
The most probable reason is that you are using wrong version of .NET Framework.
Upvotes: 5