我最近在我的Xamarin项目(具体来说是共享项目)上安装了一些Google的.NET API客户端库,以便获取与搜索查询相关的YouTube结果的链接。确切地说,我安装的三个NuGet软件包是:
Google.Apis
,v1.34.0
Google.Apis.Core
,v1.34.0
Google.Apis.YouTube.v3
,v1.34.0.1226
我的应用程序旨在跨平台,因此我确保每个软件包都安装在Android和iOS项目上。代码可以很好地编译,而我对每个包中的类所做的导入也可以很好地编译。但是,当我启动编译器时,会收到此错误:
Failed to load assembly from stream: Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Google.Apis.Core, Version=1.34.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab'
然后,当我检查整个解决方案的NuGet窗口以查看是否为两个项目都安装了该软件包时,两个框都将取消选中这三个软件包中的每个软件包(即使.csproj
文件都包含以下语句)包括每个包装)。我不确定这是否是由于不兼容引起的,因为我看到的其他不兼容的软件包都无法安装。我试过清洗溶液,甚至单独添加包装;分别添加它们时,窗口会显示为每个软件包都安装了它们,但是下次我构建时会抛出相同的错误。
有关该问题的一些信息:
为方便起见,此处列出了完整的错误日志。
Failed to load assembly from stream: Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Google.Apis.Core, Version=1.34.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab'
at Upsight.LoadedAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x001e0] in <5a7d391011b47c3aa745038310397d5a>:0
at Mono.Cecil.MetadataResolver.Resolve (Mono.Cecil.TypeReference type) [0x00038] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.ModuleDefinition.Resolve (Mono.Cecil.TypeReference type) [0x00014] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.TypeReference.Resolve () [0x00006] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.Mixin.CheckedResolve (Mono.Cecil.TypeReference self) [0x00000] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.SignatureReader.ReadCustomAttributeEnum (Mono.Cecil.TypeReference enum_type) [0x00000] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.SignatureReader.ReadCustomAttributeElementValue (Mono.Cecil.TypeReference type) [0x0002f] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.SignatureReader.ReadCustomAttributeElement (Mono.Cecil.TypeReference type) [0x00015] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.SignatureReader.ReadCustomAttributeFixedArgument (Mono.Cecil.TypeReference type) [0x00015] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.SignatureReader.ReadCustomAttributeConstructorArguments (Mono.Cecil.CustomAttribute attribute, Mono.Collections.Generic.Collection`1[T] parameters) [0x0002e] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.MetadataReader.ReadCustomAttributeSignature (Mono.Cecil.CustomAttribute attribute) [0x0003c] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.CustomAttribute.<Resolve>b__35_0 (Mono.Cecil.CustomAttribute attribute, Mono.Cecil.MetadataReader reader) [0x00000] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.ModuleDefinition.Read[TItem,TRet] (TItem item, System.Func`3[T1,T2,TResult] read) [0x00029] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.CustomAttribute.Resolve () [0x00017] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.CustomAttribute.get_ConstructorArguments () [0x00000] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.ImmediateModuleReader.ReadCustomAttributes (Mono.Cecil.ICustomAttributeProvider provider) [0x00024] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.ImmediateModuleReader.ReadProperties (Mono.Cecil.TypeDefinition type) [0x00031] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.ImmediateModuleReader.ReadType (Mono.Cecil.TypeDefinition type) [0x00068] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.ImmediateModuleReader.ReadTypes (Mono.Collections.Generic.Collection`1[T] types) [0x0000c] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.ImmediateModuleReader.ReadModule (Mono.Cecil.ModuleDefinition module, System.Boolean resolve_attributes) [0x0004f] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.ImmediateModuleReader.<ReadModule>b__2_0 (Mono.Cecil.ModuleDefinition module, Mono.Cecil.MetadataReader reader) [0x00007] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.ModuleDefinition.Read[TItem,TRet] (TItem item, System.Func`3[T1,T2,TResult] read) [0x00029] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.ImmediateModuleReader.ReadModule () [0x00000] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.ModuleReader.CreateModule (Mono.Cecil.PE.Image image, Mono.Cecil.ReaderParameters parameters) [0x0007b] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.ModuleDefinition.ReadModule (Mono.Disposable`1[T] stream, System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x0000d] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.ModuleDefinition.ReadModule (System.IO.Stream stream, Mono.Cecil.ReaderParameters parameters) [0x00012] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at Mono.Cecil.AssemblyDefinition.ReadAssembly (System.IO.Stream stream, Mono.Cecil.ReaderParameters parameters) [0x00000] in <0ea22156f1264b96bf10daa7186c2c1f>:0
at NInterpret.CecilLoader.loadStreamWithResolver (System.IO.Stream peStream, Mono.Cecil.IAssemblyResolver resolver) [0x0000f] in <5a7d38ec7eef0f2aa7450383ec387d5a>:0
at <StartupCode$Continuous-Core-Droid>.$LoadedAssemblies+TryLoadAsync@325-4.Invoke (System.Byte[] _arg2) [0x00008] in <5a7d391011b47c3aa745038310397d5a>:0
at Microsoft.FSharp.Control.AsyncBuilderImpl+args@835-1[a,b].Invoke (a a) [0x00016] in <55b16819904cf4daa74503831968b155>:0
如果有任何方法可以在不使用Google API的情况下实现我要实现的目标,那可能是规避整个问题的最佳方法。但是,我已经在此概念的WPF测试中实现了这一点,因此,如果有一个简单的解决方案,我将很高兴知道。我将提供所有必要的其他信息,但是请注意,由于我逐渐了解Xamarin的工作原理,因此可能对此没有太多帮助。