【问题标题】:The type or namespace name `Xml' does not exist in the namespace `System.Security.Cryptography'命名空间“System.Security.Cryptography”中不存在类型或命名空间名称“Xml”
【发布时间】:2017-04-08 17:25:19
【问题描述】:

我必须用 a 读取已签名的 xml

Using System.Security;
System.Security.Cryptography.Xml.SignedXml signedXml = new System.Security.Cryptography.Xml.SignedXml(lic);

第一个 Unity/VS 抱怨说

VS > 错误 11 类型或命名空间名称 Xml' does not exist in the namespaceSystem.Security.Cryptography'。你错过了一个 汇编参考?

所以我在 Visual Studio (C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Security.dll) 中添加了对 System.Security 的引用...但 Unity 一直抱怨

错误 CS0234:类型或命名空间名称 Xml' does not exist in the namespaceSystem.Security.Cryptography'。你错过了一个程序集 参考?

然后我尝试直接复制资产文件夹中的“System.Security.dll”...但仍然是相同的消息!

请问我做错了什么?必须做什么? 非常感谢!

【问题讨论】:

    标签: unity3d unityscript


    【解决方案1】:

    大部分System.Security.Cryptography 命名空间被排除在统一的默认.Net 2.0 Subset API 之外。很可能.Xml 也被剥离了。因此,请执行以下操作之一:

    1. 在 Unity 中点击 Ctrl/Cmd + Shift + B 打开构建菜单,点击player settings。在检查器中找到API Compatability Level,默认设置为.Net 2.0 Subset。将其更改为 .Net 2.0,其中包括之前剥离的其余类/命名空间。
    2. 如果错误仍然存​​在,请确保您复制到 Unity 的 .dll 来自 .net 2.0 框架。 Unity 无法导入针对高于 .net 2.0 的框架的库

    这是统一的Subset API 中排除的内容: https://docs.unity3d.com/412/Documentation/ScriptReference/MonoCompatibility.html

    抱歉,我找不到此文档的当前版本

    编辑:

    正如@user2737085 建议的那样 - 您还必须将mcs.rsp 文件添加到您的Assets 文件夹中。 mcs.rsp 应该是一个包含以下行的文本文件:

    -r:System.Security.dll
    

    【讨论】:

    • 尼卡,非常感谢您的帮助!我已经按照你的建议做了,它有效! ...但我必须在项目资产文件夹中添加一个包含“-r:System.Security.dll”的“mcs.rsp”文件!再次感谢!
    • @user2737085 酷,我已经为未来迷失的灵魂编辑了答案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-19
    • 1970-01-01
    • 2012-05-28
    • 1970-01-01
    • 1970-01-01
    • 2018-05-09
    • 2022-01-11
    相关资源
    最近更新 更多