【发布时间】:2021-02-26 23:06:48
【问题描述】:
我需要将 Firebase 的 firestore 功能添加到我的应用(后台 UWP 应用)中,该应用在运行 Windows 10 IOT Core 的树莓 (ARM) 上运行。
我设法使应用程序在我的 PC 上完全运行(其中包含 firestore)并将其部署到树莓派上,但应用程序启动时出现错误:
Error: Value cannot be null. Parameter name: path1
at System.IO.Path.Combine(String, String) + 0x2c
at Grpc.Core.Internal.NativeExtension.LoadUnmanagedLibrary() + 0x36
at Grpc.Core.Internal.NativeExtension.LoadNativeMethods() + 0x28
at Grpc.Core.Internal.NativeExtension..ctor() + 0x12
at Grpc.Core.Internal.NativeExtension.Get() + 0x4a
at Grpc.Core.GrpcEnvironment.GrpcNativeInit() + 0x48
at Grpc.Core.GrpcEnvironment..ctor() + 0x64
at Grpc.Core.GrpcEnvironment.AddRef() + 0x54
at Grpc.Core.Channel..ctor(String, ChannelCredentials, IEnumerable`1) + 0xa8
at Google.Api.Gax.Grpc.GrpcCore.GrpcCoreAdapter.CreateChannelImpl(String, ChannelCredentials, GrpcChannelOptions) + 0x24
at Google.Api.Gax.Grpc.GrpcAdapter.CreateChannel(String, ChannelCredentials, GrpcChannelOptions) + 0x16
at Google.Api.Gax.Grpc.ChannelPool.GetChannel(GrpcAdapter, String, GrpcChannelOptions, ChannelCredentials) + 0x58
at Google.Api.Gax.Grpc.ChannelPool.GetChannel(GrpcAdapter, String, GrpcChannelOptions) + 0x1a8
at Google.Api.Gax.Grpc.ClientBuilderBase`1.CreateCallInvoker() + 0x5e
at Google.Cloud.Firestore.V1.FirestoreClientBuilder.BuildImpl() + 0x16
at Google.Cloud.Firestore.FirestoreDbBuilder.Build() + 0x1ee
at Google.Cloud.Firestore.FirestoreDb.Create(String, FirestoreClient) + 0x1bc
at Processing.Service.Firestore.<Initialize>d__22.MoveNext() + 0xc4
我尝试取消选中“使用 .net Native 工具链编译”项目选项,但现在我收到以下错误:
Error loading native library "C:\Data\Programs\WindowsApps\Service_1.1.94.0_arm\grpc_csharp_ext.x86.dll".
at Grpc.Core.Internal.UnmanagedLibrary..ctor(String[] libraryPathAlternatives)
at Grpc.Core.Internal.NativeExtension.LoadUnmanagedLibrary()
at Grpc.Core.Internal.NativeExtension.LoadNativeMethods()
...
at Google.Cloud.Firestore.V1.FirestoreClientBuilder.BuildImpl()
at Google.Cloud.Firestore.FirestoreDbBuilder.Build()
at Google.Cloud.Firestore.FirestoreDb.Create(String projectId, FirestoreClient client)
在这两种情况下,我都收到了 224 条警告,例如:
ILTransform : warning ILT0028: Found native library 'W:\Service\obj\ARM\Release\ilc\in\grpc_csharp_ext.x64.dll' with unexpected CPU architecture 'amd64', while the current build target architecture is set to 'arm'. Your application may fail to launch. Please make sure to build your application with the matching CPU architecture. Service
ILTransform : warning ILT0028: Found native library 'W:\Service\obj\ARM\Release\ilc\in\grpc_csharp_ext.x86.dll' with unexpected CPU architecture 'x86', while the current build target architecture is set to 'arm'. Your application may fail to launch. Please make sure to build your application with the matching CPU architecture. Service
MCG : warning MCG0007: Unresolved P/Invoke method 'grpc_csharp_ext!gprsharp_convert_clock_type' for method 'Grpc.Core.Internal.Timespec Grpc.Core.Internal.NativeMethods.DllImportsFromSharedLib.gprsharp_convert_clock_type(Grpc.Core.Internal.Timespec, Grpc.Core.Internal.ClockType)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs. Service
MCG : warning MCG0007: Unresolved P/Invoke method 'grpc_csharp_ext!gprsharp_free' for method 'System.Void Grpc.Core.Internal.NativeMethods.DllImportsFromSharedLib.gprsharp_free(System.IntPtr)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs. Service
注意事项:
- 设备上存在所需的 json 配置文件和环境变量。
- 我使用“应用程序包”(*.appxbundle) 在设备上部署
- 我正在使用 Windows 10 IOT Core 和 UWP 应用程序,因为这是我成功使应用程序在树莓派上运行的第一种方式,如果代码保留在 C# 中,我愿意更改它。
- 找到了一个教程 (https://dev.to/erikest/grpc-on-dotnet-core-preview3-on-raspberrypi-3-4nf4) 为 ARM 重建“grpc_csharp_ext.x86”,但它提供的是“.so”文件,而不是“.dll”。
我试过了:
- 将“LibGrpc.Arm”和“libgrpc_csharp_ext.arm7”nugets 添加到项目中。
- 将“Google.Cloud.Firestore”nuget 更新为“v2.3.0-beta1”
想法:
- 为 ARM 重建 GRPC(会生成 dll 文件吗?)
- 使用另一个 Firestore nuget(即:Xamarin)而不是 Google.Cloud.Firestore
- 使用其他 Firebase SDK(即:Web 或 Unity)
- 在 raspbian(如果可能的话)而不是 Win 10 IOT Core 上运行此 C# 服务(已尝试,同样的错误...)
- 直接使用 Firebase RPC API
我需要建议,建议,想法,伙计们......如果有人可以提供帮助,那就太棒了! :-)
谢谢
【问题讨论】:
-
由于 Firebase 应用程序正在您的 PC 上运行,您是否认为问题更多地取决于您正在使用的其他技术?
-
@MrTech 我相信 Raspberry 在 ARM 处理器上运行的事实是导致问题的原因......但是我怎样才能让它工作呢?
标签: firebase google-cloud-firestore raspberry-pi arm grpc