简体   繁体   English

类型或名称空间名称“ Xml”在名称空间“ System.Security.Cryptography”中不存在

[英]The type or namespace name `Xml' does not exist in the namespace `System.Security.Cryptography'

I have to read a signed xml with a 我必须阅读带有

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

First Unity/VS complained that First Unity / VS抱怨说

VS > Error 11 The type or namespace name Xml' does not exist in the namespace System.Security.Cryptography'. VS>错误11类型或名称空间名称Xml' does not exist in the namespace System.Security.Cryptography' Xml' does not exist in the namespace Are you missing an assembly reference? 您是否缺少装配参考?

So I added a reference to System.Security in Visual Studio (C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\System.Security.dll)...but Unity keeps complaining that 所以我在Visual Studio(C:\\ Windows \\ Microsoft.NET \\ Framework \\ v2.0.50727 \\ System.Security.dll)中添加了对System.Security的引用...但是Unity一直抱怨

error CS0234: The type or namespace name Xml' does not exist in the namespace System.Security.Cryptography'. 错误CS0234:类型或名称空间名称Xml' does not exist in the namespace System.Security.Cryptography' Xml' does not exist in the namespace Are you missing an assembly reference? 您是否缺少装配参考?

I then tried to directly copy the 'System.Security.dll' inside the asset folder...but still the same message! 然后,我尝试直接在资产文件夹中复制“ System.Security.dll” ...但仍然是相同的消息!

What am I doing wrong please? 请问我做错了什么? What has to be done? 必须做什么? Thanks very much! 非常感谢!

Most of the System.Security.Cryptography namespace is excluded from the unity's default .Net 2.0 Subset API. 单位的默认.Net 2.0 Subset API排除了大多数System.Security.Cryptography命名空间。 Most probably .Xml is also stripped. .Xml很可能也被剥离了。 So do one of the following: 因此,请执行以下任一操作:

  1. in Unity click on Ctrl/Cmd + Shift + B to open the build menu, click on player settings . 在Unity中,点击Ctrl / Cmd + Shift + B打开构建菜单,然后点击player settings In inspector find API Compatability Level which is set to .Net 2.0 Subset by default. 在检查器中找到“ API Compatability Level ,默认情况下将其设置为.Net 2.0 Subset Change it to .Net 2.0 which includes the rest of the previously stripped classes/namespaces. 将其更改为.Net 2.0 ,其中包括以前剥离的其余类/命名空间。
  2. if the error persists then make sure that the .dll you are copying into Unity is from .net 2.0 framework. 如果错误仍然存​​在,请确保要复制到Unity的.dll来自.net 2.0框架。 Unity can't import libraries targeting framework higher than .net 2.0 Unity无法导入目标框架高于.net 2.0的库

This is what is excluded from the unity's Subset API: https://docs.unity3d.com/412/Documentation/ScriptReference/MonoCompatibility.html 这是单位的Subset API排除的内容: https : //docs.unity3d.com/412/Documentation/ScriptReference/MonoCompatibility.html

Sorry, I couldn't find the current version of this document 抱歉,我找不到此文档的当前版本

EDIT: 编辑:

as @user2737085 suggested - you'd also have to add mcs.rsp file to your Assets folder. 按照@ user2737085的建议-您还必须将mcs.rsp文件添加到Assets文件夹中。 mcs.rsp should be a text file containing the following line: mcs.rsp应该是包含以下行的文本文件:

-r:System.Security.dll

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 命名空间“System.IO”中不存在类型或命名空间名称“Ports”(您是否缺少程序集引用?) - The type or namespace name 'Ports' does not exist in the namespace 'System.IO' (are you missing an assembly reference?) 类型或名称空间名称“ Kinect”在名称空间“ Microsoft”中不存在 - The type or namespace name `Kinect' does not exist in the namespace `Microsoft' 命名空间“UnityEngine.Rendering”中不存在类型或命名空间名称“PostProcessing” - The type or namespace name `PostProcessing' does not exist in the namespace `UnityEngine.Rendering' "命名空间“UnityEngine”中不存在类型或命名空间名称“UI”" - The type or namespace name 'UI' does not exist in the namespace 'UnityEngine' 命名空间“UnityEngine”中不存在 Unity 类型或命名空间名称“InputSystem” - Unity type or namespace name 'InputSystem' does not exist in the namespace 'UnityEngine' 命名空间“UnityEditor.Experimental”中不存在类型或命名空间名称“SceneManagement” - The type or namespace name `SceneManagement' does not exist in the namespace `UnityEditor.Experimental' Unity 中的命名空间“UnityEngine”中不存在类型或命名空间名称“Windows” - The type or namespace name `Windows' does not exist in the namespace `UnityEngine' in Unity Unity 类型或命名空间名称“空间跟踪”在命名空间“UnityEngine”中不存在 - Unity type or namespace name 'Spatial Tracking' does not exist in the namespace 'UnityEngine' 命名空间“UnityEditor”中不存在类型或命名空间名称“Animations” - The type or namespace name 'Animations' does not exist in the namespace 'UnityEditor' 命名空间“UnityEngine.Experimental”中不存在类型或命名空间名称“Input” - The type or namespace name 'Input' does not exist in the namespace 'UnityEngine.Experimental'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM