【问题标题】:Xamarin, Grpc, Could not resolve type with token 0100002bXamarin,Grpc,无法使用令牌 0100002b 解析类型
【发布时间】:2017-10-16 07:38:28
【问题描述】:

我正在尝试让 gRPC 与 Xamarin 一起工作。

我知道您可能认为这是重复的问题,因为在 stackoverflow 上有类似的问题关于该错误,但我已尝试合并所有引用和 nuget 包,尝试清理项目并重建。

我在 Windows 7 和 Windows 10 上尝试过 Xamarin.Forms、Xamarin Android 项目。它们都有相同的错误。获取异常:

Channel channel = new Channel(ip, port, ChannelCredentials.Insecure);

例外:

"Could not resolve type with token 0100002b (from typeref, class/assembly System.Runtime.Loader.AssemblyLoadContext, System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)"

输出:

10-16 10:19:28.057 D/Mono(13519): Assembly Ref addref Grpc.Core[0x7f9e5ad500] -> System.Core[0x7f89b19500]: 4
10-16 10:19:28.062 D/Mono    (13519): Image addref System[0x7f89750280] -> System.dll[0x7f89a5e000]: 2
10-16 10:19:28.062 D/Mono(13519): Prepared to set up assembly 'System' (System.dll)
10-16 10:19:28.062 D/Mono(13519): Assembly System[0x7f89750280] added to domain RootDomain, ref_count = 1
10-16 10:19:28.076 D/Mono(13519): AOT: image 'System.dll.so' not found: dlopen failed: library "/data/app/GarmentInventoryAndroidApp.GarmentInventoryAndroidApp-1/lib/arm64/libaot-System.dll.so" not found
10-16 10:19:28.084 D/Mono(13519): AOT: image '/usr/local/lib/mono/aot-cache/arm64/System.dll.so' not found: dlopen failed: library "/data/app/GarmentInventoryAndroidApp.GarmentInventoryAndroidApp-1/lib/arm64/libaot-System.dll.so" not found
10-16 10:19:28.084 D/Mono(13519): Config attempting to parse: 'System.dll.config'.
10-16 10:19:28.084 D/Mono(13519): Config attempting to parse: '/usr/local/etc/mono/assemblies/System/System.config'.
10-16 10:19:28.084 D/Mono(13519): Assembly Ref addref System.Core[0x7f89b19500] -> System[0x7f89750280]: 2
10-16 10:19:28.085 D/Mono    (13519): Assembly Ref addref System[0x7f89750280] -> mscorlib[0x7fb0aa3e00]: 16
Loaded assembly: System.dll[External]
10-16 10:19:28.134 D/Mono(13519): Assembly Loader probing location: '/storage/emulated/0/Android/data/GarmentInventoryAndroidApp.GarmentInventoryAndroidApp/files/.__override__/System.Runtime.Loader.dll'.
10-16 10:19:28.134 D/Mono(13519): Image addref System.Runtime.Loader[0x7f89750380] -> /storage/emulated/0/Android/data/GarmentInventoryAndroidApp.GarmentInventoryAndroidApp/files/.__override__/System.Runtime.Loader.dll[0x7f8975e800]: 2
10-16 10:19:28.135 D/Mono(13519): Prepared to set up assembly 'System.Runtime.Loader' (/storage/emulated/0/Android/data/GarmentInventoryAndroidApp.GarmentInventoryAndroidApp/files/.__override__/System.Runtime.Loader.dll)
10-16 10:19:28.135 D/Mono(13519): Assembly System.Runtime.Loader[0x7f89750380] added to domain RootDomain, ref_count= 1
10-16 10:19:28.138 D/Mono    (13519): AOT: image '/storage/emulated/0/Android/data/GarmentInventoryAndroidApp.GarmentInventoryAndroidApp/files/.__override__/System.Runtime.Loader.dll.so' not found: dlopen failed: library "/data/app/GarmentInventoryAndroidApp.GarmentInventoryAndroidApp-1/lib/arm64/libaot-System.Runtime.Loader.dll.so" not found
10-16 10:19:28.143 D/Mono(13519): AOT: image '/usr/local/lib/mono/aot-cache/arm64/System.Runtime.Loader.dll.so' not found: dlopen failed: library "/data/app/GarmentInventoryAndroidApp.GarmentInventoryAndroidApp-1/lib/arm64/libaot-System.Runtime.Loader.dll.so" not found
10-16 10:19:28.143 D/Mono(13519): Assembly Loader loaded assembly from location: '/storage/emulated/0/Android/data/GarmentInventoryAndroidApp.GarmentInventoryAndroidApp/files/.__override__/System.Runtime.Loader.dll'.
10-16 10:19:28.143 D/Mono(13519): Config attempting to parse: '/storage/emulated/0/Android/data/GarmentInventoryAndroidApp.GarmentInventoryAndroidApp/files/.__override__/System.Runtime.Loader.dll.config'.
10-16 10:19:28.143 D/Mono(13519): Config attempting to parse: '/usr/local/etc/mono/assemblies/System.Runtime.Loader/System.Runtime.Loader.config'.
10-16 10:19:28.143 D/Mono(13519): Assembly Ref addref Grpc.Core[0x7f9e5ad500] -> System.Runtime.Loader[0x7f89750380]: 2
10-16 10:19:28.144 W/Mono    (13519): The request to load the assembly mscorlib v4.0.0.0 was remapped to v2.0.5.0
10-16 10:19:28.144 D/Mono(13519): Assembly Ref addref System.Runtime.Loader[0x7f89750380] -> mscorlib[0x7fb0aa3e00]: 17
Loaded assembly: /storage/emulated/0/Android/data/GarmentInventoryAndroidApp.GarmentInventoryAndroidApp/files/.__override__/System.Runtime.Loader.dll[External]

希望有人能帮助我。提前致谢!

【问题讨论】:

  • 请注意 gRPC C# 目前没有对 Xamarin 的官方支持(我们使用的是原生 C 库和核心 RPC 功能并通过 P/Invoke 调用它 - 我认为可能是您可能会看到问题的根本原因。gRPC C# 可以为 Xamarin 工作,但它需要构建正确版本的 grpc_csharp_ext.dll 本机库正在手动构建(可能还有一些调整)。
  • @janTattermusch 谢谢你的回答。

标签: c# android xamarin grpc


【解决方案1】:

感谢@JanTattermusch 的回答:

请注意 gRPC C# 目前没有官方支持 对于 Xamarin(我们使用本机 C 库和核心 RPC 功能并通过 P/Invoke 调用它——我认为这可能是 您可能看到的问题的根本原因。 gRPC C# 可以制作 为 Xamarin 工作,但它需要构建正确的版本 正在手动构建的 grpc_csharp_ext.dll 本机库(并且可能 还有一些调整)。

【讨论】:

  • 能否分享一下上述问题的解决方法?我在尝试连接 Google 的数据存储区时遇到了同样的问题。
猜你喜欢
  • 1970-01-01
  • 2017-05-01
  • 1970-01-01
  • 2017-02-06
  • 2020-09-07
  • 1970-01-01
  • 2019-02-19
  • 2020-06-27
  • 2017-03-09
相关资源
最近更新 更多