Xamarin:错误MT2002:无法解析“System.Void System.Security.Cryptography.SHA1Cng ::。ctor()” [英] Xamarin: Error MT2002: Failed to resolve "System.Void System.Security.Cryptography.SHA1Cng::.ctor()"
问题描述
我在构建适用于iOS的Xamarin解决方案时遇到此错误。
我已启用链接SDK程序集。
奇怪的是,当我为模拟器构建它时,它工作正常,但是当我为真实设备构建它时会出现此错误。
I'm getting this error when building my Xamarin solution for iOS.
I have enabled link SDK assemblies only.
Strange thing is, it works just fine when I build it for the simulator, but when I build for a real device it gives this error.
MTOUCH: error MT2002: Failed to resolve "System.Void
System.Security.Cryptography.SHA1Cng::.ctor()" reference from
"System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
我的代码中没有指向System.Security.Cryptography。
No where in my code am I refering to System.Security.Cryptography.
当我禁用链接程序集或启用链接所有程序集时它会起作用,但链接所有会导致Unity IoC失败并禁用所有链接会导致应用程序的文件大小更大。
It works when I disable linking assemblies, or enable link all assemblies, but linking all will cause Unity IoC to fail and disable linking all together results in a larger file size for the app.
我正在为.NET版本构建目标OS 7.1(当我更改它时没有区别) 4.5.2并安装了Xamarin的所有更新。
I'm building for target OS 7.1 (no difference when I change that) for .NET version 4.5.2 and all updates for Xamarin are installed.
更新:
我可以确认我的iOS项目是指System.Core版本2.0.5.0
请参阅下面的截图。< br>
但是,我确实有一个被引用的PCL项目。可能以某种方式导致问题吗?
Update:
I can confirm that my iOS project is referring to System.Core version 2.0.5.0
See the screenshot below.
However, I do have a PCL project that is referenced. Could that somehow cause the issue?
更新:
原来有一个我正在引用的库HashLib,我认为它是PCL但是实际上不是。
在HashLib中有一个调用System.Core中的某些东西导致链接器失败。
我现在从HashLib中提取了我需要的功能并编译它进入了一个单独的PCL项目,这解决了我的链接器问题。
UPDATE:
Turns out there is a library that I was referencing, HashLib, which I thought was a PCL but actually isn't.
Within HashLib there was a call to something in System.Core which caused the linker to fail.
I have now extracted the functionality I needed from HashLib and compiled it into a separate PCL project and this has fixed my linker issue.
推荐答案
你以某种方式引用了桌面版的System。核心:
You're somehow referencing the desktop version of System.Core:
System.Core,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089
"System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
Xamarin.iOS版本有版本= 2.0.5.0
。
The Xamarin.iOS version has Version=2.0.5.0
.
请注意,您可能不会自己引用此版本的System.Core,它可以间接引入(如果你引用一个引用System.Core的程序集。。
Note that you may not reference this version of System.Core yourself, it can be pulled in indirectly (if you reference an assembly that references System.Core).
验证你的所有引用都使用2.0.5.0版本的System.Core(我相信你可以使用Reflector来实现这一点) )。
Verify that all your references use the 2.0.5.0 version of System.Core (I believe you can use Reflector for this).
这篇关于Xamarin:错误MT2002:无法解析“System.Void System.Security.Cryptography.SHA1Cng ::。ctor()”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!