1

我在我的 .NET 5 aspnet 核心应用程序中使用 Google.Cloud.SecretManager.V1。我正在容器化应用程序以在 GCP Cloud 上作为 linux 容器运行。创建 SecretManagerServiceClient 时出现以下异常

//call SDK
SecretManagerServiceClient client = SecretManagerServiceClient.Create();


System.DllNotFoundException: Unable to load shared library 'libdl.so' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibdl.so: cannot open shared object file: No such file or directory
   at Grpc.Core.Internal.UnmanagedLibrary.Linux.dlopen(String filename, Int32 flags)
   at Grpc.Core.Internal.UnmanagedLibrary.LoadLibraryPosix(Func`3 dlopenFunc, Func`1 dlerrorFunc, String libraryPath, String& errorMsg)
   at Grpc.Core.Internal.UnmanagedLibrary.PlatformSpecificLoadLibrary(String libraryPath, String& errorMsg)
   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 Google.Api.Gax.Grpc.GrpcCore.GrpcCoreAdapter.CreateChannelImpl(String endpoint, ChannelCredentials credentials, GrpcChannelOptions options)
   at Google.Api.Gax.Grpc.GrpcAdapter.CreateChannel(String endpoint, ChannelCredentials credentials, GrpcChannelOptions options)
   at Google.Api.Gax.Grpc.ChannelPool.GetChannel(GrpcAdapter grpcAdapter, String endpoint, GrpcChannelOptions channelOptions, ChannelCredentials credentials)
   at Google.Api.Gax.Grpc.ChannelPool.GetChannel(GrpcAdapter grpcAdapter, String endpoint, GrpcChannelOptions channelOptions)
   at Google.Api.Gax.Grpc.ClientBuilderBase`1.CreateCallInvoker()
   at Google.Cloud.SecretManager.V1.SecretManagerServiceClientBuilder.BuildImpl()
   at Google.Cloud.SecretManager.V1.SecretManagerServiceClientBuilder.Build()
   at Google.Cloud.SecretManager.V1.SecretManagerServiceClient.Create()

如果我使用 aspnetcore 3.1 图像,相同的代码可以正常工作。NET 5 应该是 .NET core 3.1 的升级,并且向后兼容。所以,我很好奇,可以做些什么来使这段代码在 .NET 5 上运行

4

1 回答 1

1

我发布了这个答案,以使评论部分的解决方案更加明显。

正如@John Hanley所建议并由@SmartCoder确认的那样,此问题已通过添加到以下 Docker 文件行来解决:

RUN apt-get update -y 
RUN apt-get install -y libc6-dev 
于 2021-04-06T08:52:09.003 回答