无法在 CentOS 7 上使用 Apache 和 mod_mono 加载本机 gRPC 库

Cannot load native gRPC libraries with Apache and mod_mono on CentOS 7

我正在开发一个使用 gRPC 库的 ASP.NET Wep API 应用程序。在 Windows 上它工作正常,但如果它在 Linux 上使用 Apache 和 mod_mono,我得到以下异常:

- ChangeConfigurationAsync(): gRPC call failed with exception=[System.IO.FileNotFoundException: Message="Error loading native library. Not found in any of the possible locations: /tmp/apache-temp-aspnet-0/17ae072c/assembly/shadow/bc23f1e5/69f27fa4_d5d18e41_00000001/libgrpc_csharp_ext.x64.so,
/tmp/apache-temp-aspnet-0/17ae072c/assembly/shadow/bc23f1e5/69f27fa4_d5d18e41_00000001/runtimes/linux/native/libgrpc_csharp_ext.x64.so,
/tmp/apache-temp-aspnet-0/17ae072c/assembly/shadow/bc23f1e5/69f27fa4_d5d18e41_00000001/../../runtimes/linux/native/libgrpc_csharp_ext.x64.so"

, StackTrace="  
at Grpc.Core.Internal.UnmanagedLibrary.FirstValidLibraryPath (System.String[] libraryPathAlternatives) [0x00042] in <f30adad8041c4e6ba2a109e705aeb795>:0 \n  
at Grpc.Core.Internal.UnmanagedLibrary..ctor (System.String[] libraryPathAlternatives) [0x00006] in <f30adad8041c4e6ba2a109e705aeb795>:0 \n  
at Grpc.Core.Internal.NativeExtension.Load () [0x00044] in <f30adad8041c4e6ba2a109e705aeb795>:0 \n  
at Grpc.Core.Internal.NativeExtension..ctor () [0x00006] in <f30adad8041c4e6ba2a109e705aeb795>:0 \n  
at Grpc.Core.Internal.NativeExtension.Get () [0x00022] in <f30adad8041c4e6ba2a109e705aeb795>:0 \n  
at Grpc.Core.Internal.NativeMethods.Get () [0x00000] in <f30adad8041c4e6ba2a109e705aeb795>:0 \n  
at Grpc.Core.GrpcEnvironment.GrpcNativeInit () [0x00000] in <f30adad8041c4e6ba2a109e705aeb795>:0 \n  
at Grpc.Core.GrpcEnvironment..ctor () [0x0001e] in <f30adad8041c4e6ba2a109e705aeb795>:0 \n  
at Grpc.Core.GrpcEnvironment.AddRef () [0x00028] in <f30adad8041c4e6ba2a109e705aeb795>:0 
at Grpc.Core.Channel..ctor (System.String target, Grpc.Core.ChannelCredentials credentials, System.Collections.Generic.IEnumerable`1[T] options) [0x00051] in <f30adad8041c4e6ba2a109e705aeb795>:0 
at Grpc.Core.Channel..ctor (System.String host, System.Int32 port, Grpc.Core.ChannelCredentials credentials, System.Collections.Generic.IEnumerable`1[T] options) [0x00012] in <f30adad8041c4e6ba2a109e705aeb795>:0 
at MediaGateway.Shared.ConfigurationChangeInterface.Impl.ConfigurationChangeClient+<ChangeConfigurationAsync>d__6.MoveNext () [0x000da] in <208a1a3cb2734ae9bbbbc700fc47e4cd>:0 "] ({})

libgrpc_csharp_ext.x64.so 与其他托管 DLL 放在相同的 "bin" 目录中,但不幸的是,.so 文件未复制到卷影副本目录。

据我所知,无法将 gRPC 库配置为在其他目录中查找非托管库。我们的其他单声道守护进程也没有问题,通常使用 gRPC "mono xy.exe" 启动。

我们正在使用:

您可以尝试在 Web.config:

中设置 shadowCopyBinAssemblies="false"
<system.web>
    <hostingEnvironment shadowCopyBinAssemblies="false"/>
</system.web>

旧的 MSDN 文档(在 docs.microsoft.com 上找不到): https://msdn.microsoft.com/en-us/library/ms228159(v=vs.100).aspx