Visual Studio Does not recognize System.Linq

谁说我不能喝 提交于 2020-01-27 08:35:50

问题


I created this program and C# and it worked correctly a few weeks ago. Now, I copied all of this code to a another project I am working on. I added it to a brand new C# Class inside of the project I am working on. Visual Studio didn't recognize the assembly references that say "not found" in the comments.

This is just bizarre since they were found in the previous program. Does anyone know why Visual Studio can't find these assembly references.

using System;

using System.Collections.Generic;

using System.Linq;    //not found
using System.Text;
using XML_Creator;     //not found
using System.Xml.Linq; //not found
using System.IO;

回答1:


An educated guess: It's probably the .NET framework target version of the new project.

System.Linq was introduced on .NET Framework 3.5.

Go to Project -> Properties -> Application and check the Target Framework property. It's probably a target framework prior to 3.5




回答2:


You need to add refrence to system.Core.




回答3:


  • Step 1) Go to your Project Solution Explorer and Select References
  • Step 2) Right click it on References and Select Add Reference... a form will appear
  • Step 3) Search linq on Search bar
  • Step 4) Now Select/tick the System.XML.Linq checkbox
  • Step 5) Click Ok



回答4:


You need to right click on the solution in Solution Explorer and add a reference to System.Xml.Linq and/or System.Linq in Project Properties.

This has hit me several times - I see it a lot with System.Configuration as well. (For some reason those two references seem to be particularly picky)




回答5:


If your file is in App_Code folder, try moving it to another folder. For me its solved the problem.




回答6:


For me I tried this and worked:

PROJECT==>Add Reference ==> Browse ==> C:\Windows\winsxs\x86_netfx35linq-system.core_31bf3856ad364e35_6.1.7601.17514_none_6161fc35ed136622\System.core.dll

Or

you can simply find the System.core.dll using windows search on Os System Drive




回答7:


I had a similar issue. I upgraded my asp.net project to .NET Framework 4.5.x and it worked. I did tried 4.5.1 first and then later 4.5.0 and both seem to be helping.



来源:https://stackoverflow.com/questions/24659934/visual-studio-does-not-recognize-system-linq

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!