-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Allow customizing NativeLibrary path in .NET Framework #25211
Description
Is your feature request related to a problem? Please describe.
I'm working on a big legacy project which has a strong dependency to a particular nuget project that internally has another dependency that tries to load all .dll files inside /bin. When it tries to load grpc_csharp_ext.x86.dll or grpc_csharp_ext.x64.dll it throws System.BadImageFormatException (when trying to get the assemby name via AssemblyName.GetAssemblyName). The problem is this dependency is very old and its source code is nowhere to be found so the only solutions I'm seeing would be to migrate this big dependency out of the legacy codebase, which would be pretty hard, or move grpc_csharp_ext.x64.dll and grpc_csharp_ext.x86.dll out of /bin and customize the loading path.
Describe the solution you'd like
There's already a TODO in the code, so I was hopeful that this could become a feature - I know that the problem I'm facing is not a grpc issue per se, I'm opening this issue just because this TODO would solve my problem
grpc/src/csharp/Grpc.Core/Internal/NativeExtension.cs
Lines 85 to 87 in 3f011c2
| // TODO: allow customizing path to native extension (possibly through exposing a GrpcEnvironment property). | |
| // See https://github.com/grpc/grpc/pull/7303 for one option. | |
| var assemblyDirectory = GetAssemblyDirectory(); |
For my use case allowing customizing the NativeLibrary directory on .NET Framework via environment variable would suffice