Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to use XDocument class inside a Unity3D project on Windows 7.

I did the following:

  • added the reference System.Xml.Linq to 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
160 views
Welcome To Ask or Share your Answers For Others

1 Answer

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:

Try dragging the C:Program Files (x86)UnityEditorDataMonolibmono2.0System.Xml.Linq.dll file into the unity project window like you would a texture or other game asset.

If none of these yield ANY luck for you, then I'm afraid you are out of luck.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...