如何在Mono中使用XDocument类 [英] How to use XDocument class in Mono

查看:56
本文介绍了如何在Mono中使用XDocument类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Windows 7上的Unity3D项目内使用XDocument类.

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

我做了以下事情:

  • 将参考System.Xml.Linq添加到了Mono项目.
  • 包括名称空间:

  • added the reference System.Xml.Linq to the Mono project.
  • included the namespace:

using System.Xml.Linq;

  • 将目标框架设置为:Mono/.NET 3.5
  • 清理并重建项目
  • set the target framework to: Mono/.NET 3.5
  • clean and rebuild the project
  • 但仍然Unity3D对此有所抱怨.这是控制台中的错误输出:

    But still Unity3D complains about it. Here's the error output in the console:

    资产/脚本/编辑器/RoadManager/RoadManager.cs(3,18):错误CS0234: 类型或名称空间名称"Linq"在名称空间中不存在 `System.Xml'.您是否缺少装配参考?

    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?

    有什么主意吗?

    推荐答案

    已对此进行了讨论 很多 时间

    This has been discussed many times before, but few of these answers are complete.

    如前所述,Unity3d最多仅支持.NET 2.0版,并且System.Xml.Linq似乎是在.NET 3.5中引入的,除了它没有在

    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.

    唯一可以尝试的方法是将Mono API兼容性级别设置为2.0(菜单:编辑">项目设置">播放器",然后在其他设置"面板中查看),但这似乎是Linq2SQL的错误解决方案

    另一种可能的解决方案是将DLL自己添加到Unity编辑器中,如下所示:

    Another possible solution is to add the DLL yourself into the Unity Editor as shown:

    尝试拖动C:\ Program文件 (x86)\ Unity \ Editor \ Data \ Mono \ lib \ mono \ 2.0 \ System.Xml.Linq.dll文件 进入纹理项目或其他游戏的统一项目窗口 资产.

    Try dragging the C:\Program Files (x86)\Unity\Editor\Data\Mono\lib\mono\2.0\System.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.

    这篇关于如何在Mono中使用XDocument类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆