开发者

C# using System.Linq error

Why 开发者_如何学运维might "using System.Linq" cause the following error?

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


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


The most probable reason is that you are using wrong version of .NET Framework.


Try to add System.Core assembly to your project


You'll get this error if you don't have "System.Core.dll" referenced (the assembly which contains the core LINQ APIs).


System.Linq is available in .Net 3.5 and above version.


Maybe you're targeting an older framework, Linq came in with 3.5 IIRC.


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.


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.


In my case the only thing that worked was:

Adding a new Razor item (e.g. MVC 5 View Page)

C# using System.Linq error

That automatically pulls in some NuGet packages

C# using System.Linq error

The package that makes System.Linq available to Razor Views IntelliSense seems to be Microsoft.AspNet.WebPages.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜