簡體   English   中英

類型或名稱空間名稱“ Xml”在名稱空間“ System.Security.Cryptography”中不存在

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

我必須閱讀帶有

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

First Unity / VS抱怨說

VS>錯誤11類型或名稱空間名稱Xml' does not exist in the namespace System.Security.Cryptography' Xml' does not exist in the namespace 您是否缺少裝配參考?

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

錯誤CS0234:類型或名稱空間名稱Xml' does not exist in the namespace System.Security.Cryptography' Xml' does not exist in the namespace 您是否缺少裝配參考?

然后,我嘗試直接在資產文件夾中復制“ System.Security.dll” ...但仍然是相同的消息!

請問我做錯了什么? 必須做什么? 非常感謝!

單位的默認.Net 2.0 Subset API排除了大多數System.Security.Cryptography命名空間。 .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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM