Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2015, missing library System.Xml.Linq

Sorry for the noob-sounding question, but I'm doing a project for school where I need to query some data from an XML file, a format that i have exactly zero experience with so I'm not sure I'm doing it right.

After checking out a bunch of different languages, I decided that the C# library LINQ to XML looks like the easiest, syntactically speaking, to work with so I'm gonna roll with it. I've never really worked in C# before but I have a ton of experience in Java, C, and C++ so I'm confident I can pick it up quickly.

It was my understanding that the library already came with C# when I downloaded the language when I first installed Visual Studio (Which I have never worked with before this class I'm in now so I'm not sure 100% how it works.)

After checking out a tutorial, I was alerted that I could utilize the library by including using System.Xml.Linq. However, when I tried the basic command XDocument xmlDocument = new XDocument(), I got an error that "XDocument" could not be found, and another error that Linq doesn't exist within the System.Xml namespace.

I'm really stuck because it's pretty much the consensus that our professor isn't very good and I've asked around but nobody in the class really knows what to do so asking my peers hasn't been any help.

Thanks for your patience and any available help you guys can give me.

like image 591
Ethan Fox Avatar asked Sep 14 '25 06:09

Ethan Fox


2 Answers

Go to project references and add a reference to System.Xml.Linq :

enter image description here

How to: Add or Remove References By Using the Add Reference Dialog Box

like image 186
Mitch Wheat Avatar answered Sep 17 '25 00:09

Mitch Wheat


I think you are confused.

System.Xml and System.Xml.Linq are two different references.

You will have to add System.Xml.Linq, then call using System.Xml.Linq in your namespace.

like image 44
active92 Avatar answered Sep 17 '25 01:09

active92