I’m trying to use XDocument class inside a Unity3D project on Windows 7.
I did the following:
- added the reference
System.Xml.Linqto the Mono project. -
included the namespace:
using System.Xml.Linq; - set the target framework to:
Mono/.NET 3.5 - clean and rebuild the project
But still Unity3D complains about it. Here’s the error output in the console:
Assets/Scripts/Editor/RoadManager/RoadManager.cs(3,18): error CS0234:
The type or namespace name `Linq’ does not exist in the namespace
`System.Xml’. Are you missing an assembly reference?
Any idea?
This has been discussed many times before, but few of these answers are complete.
As has been said before, Unity3d only supports up to .NET version 2.0, and it seems System.Xml.Linq was introduced in .NET 3.5, besides the fact that it is not listed on the Unity3d compatibility list anywhere.
The only things to try are to set the Mono API compatibility level to 2.0 (Menu: Edit > Project Settings > Player and look in the Other Settings panel), but it seems that that was a mistaken solution for Linq2SQL.Another possible solution is to add the DLL yourself into the Unity Editor as shown:
If none of these yield ANY luck for you, then I’m afraid you are out of luck.