我正在为 Csharp 使用 .NET 核心和 gRPC 构建一个 Web API 应用程序。
在本地,它工作得很好,但是当我构建容器并在 Docker 桌面上运行它时,调用方法时收到错误:
System.IO.IOException: Error loading native library "/app/runtimes/linux/native/libgrpc_csharp_ext.x64.so". Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /app/runtimes/linux/native/libgrpc_csharp_ext.x64.so)
at Grpc.Core.Internal.UnmanagedLibrary..ctor(String[] libraryPathAlternatives)
at Grpc.Core.Internal.NativeExtension.LoadUnmanagedLibrary()
at Grpc.Core.Internal.NativeExtension.LoadNativeMethods()
at Grpc.Core.Internal.NativeExtension..ctor()
at Grpc.Core.Internal.NativeExtension.Get()
at Grpc.Core.Internal.NativeMethods.Get()
at Grpc.Core.GrpcEnvironment.GrpcNativeInit()
at Grpc.Core.GrpcEnvironment..ctor()
at Grpc.Core.GrpcEnvironment.AddRef()
at Grpc.Core.Channel..ctor(String target, ChannelCredentials credentials, IEnumerable`1 options)
at Net.Core.Grpc.IPEndpointStrategy.SetCallInvokers(String serviceName, Boolean filterBlack)
at Net.Core.Grpc.IPEndpointStrategy.Get(String serviceName)
at Net.Core.Grpc.ClientCallInvoker.Call[TResponse](Func`2 call, Int32 retryLeft)
at Net.Core.Grpc.ClientCallInvoker.AsyncUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request) …Run Code Online (Sandbox Code Playgroud)