What is wrong with this code ? (Linq)

Hi all,

The following code :

using System;

using System.IO;
using System.Xml;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Linq;

namespace AlmaRestTest
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			XElement root = XElement.Load("TestConfig.xml");
			IEnumerable<XElement> tests =
    			from el in root.Elements("Test")
    			where (string)el.Element("CommandLine") == "Examp2.EXE"
    			select el;

			foreach (XElement el in tests)
    			Console.WriteLine((string)el.Attribute("TestId"));

			Console.ReadLine();
		}
	}
}

get the following error :

Assets/NewBehaviourScript.cs(4,18): error CS0234: The type or namespace name `Linq' does not exist in the namespace `System.Xml'. Are you missing an assembly reference?

So whats wrong here ? - I can add a reference to System.Xml.Linq, but either unity deletes it or gives the error. I can still see things XElement in MonoDevelop in IntelliSense after adding the reference but it still fails when I return to Unity?!

System.Xml.Linq does not exist in Mono, I think. If you want third party libraries to compile with unity, you need to drag them into your asset folder. There is no guarantee, however, that System.Xml.Linq (whatever library its physically in) will play nice with Unity.

It’s just System.Linq - I use linq queries in my game, and it works fine.

To be clear, a System.Xml.Linq DOES exist in .NET Framework 4.