I'm developing an ASP.NET Wep API application which uses the gRPC library. On Windows it is working fine, but if it is running on Linux with Apache and mod_mono, I get the following exception:
- 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 "] ({})
The libgrpc_csharp_ext.x64.so is placed in the same "bin" Directory as the other managed DLLs, but unfortunately the .so file is not copied to the shadow copy directories.
As far as I've seen, the gRPC library cannot be configured to look in other directories for unmanaged libraries. We also have no problems with our other mono daemons normally started with "mono xy.exe" using gRPC.
We are using:
You could try to set shadowCopyBinAssemblies="false" in your Web.config:
<system.web>
<hostingEnvironment shadowCopyBinAssemblies="false"/>
</system.web>
Old MSDN documentation (didn't find it on learn.microsoft.com): https://msdn.microsoft.com/en-us/library/ms228159(v=vs.100).aspx