Skip to content

Native libraries search path is wrong in GAC scenario #25274

@fabsenet

Description

@fabsenet

This may be related to #18737

What version of gRPC and what language are you using?

grpc 2.34.1 (client)
C# on .net framework 4.7.2

What operating system (Linux, Windows,...) and version?

Windows Server 2016

What runtime / compiler are you using (e.g. python version or version of gcc)

x64

What did you do?

The legacy app I am working on relies on having its DLLs in the global assembly cache (GAC). I added a reference to GRPC and put all DLLs of it in the GAC as well. Namely Google.Protobuf.dll , Grpc.Core.dll and Grpc.Core.Api.dll

These DLLs are signed which is required for them to be put in the GAC so I think this is a supported usecase.

What did you expect to see?

A successful load and start of the GRPC client in my application. (if I load my code in a non-GAC test case, it just works)

What did you see instead?

If I now run the application, it fails to load, because It wants to load the native dll but cannot:

System.IO.FileNotFoundException: Error loading native library. Not found in any of the possible locations: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Grpc.Core\v4.0_2.0.0.0__d754f35622e28bad\grpc_csharp_ext.x64.dll
   at Grpc.Core.Internal.UnmanagedLibrary.FirstValidLibraryPath(String[] libraryPathAlternatives)
   at Grpc.Core.Internal.UnmanagedLibrary..ctor(String[] libraryPathAlternatives)
   at Grpc.Core.Internal.NativeExtension.LoadNativeMethodsLegacyNetFramework()
   at Grpc.Core.Internal.NativeExtension..ctor()
   at Grpc.Core.Internal.NativeExtension.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)

The source for the search path might be here:
https://github.com/grpc/grpc/blob/master/src/csharp/Grpc.Core/Internal/NativeExtension.cs#L83

Anything else we should know about your project / environment?

I need to stay with the GAC because of legacy requirements :-(

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions