grpc/grpc-dotnet

Client whit .net Framework 4.8.1 and 4.6.2 Error

drdelportillo opened this issue · 2 comments

What version of gRPC and what language are you using?

The version of nuguet grpc.net.client is 2.66.0
C# is a language

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

Windows 11

What runtime / compiler are you using (e.g. .NET Core SDK version dotnet --info)

.net Framework 4.8.1 and 4.6.2

What did you do?

I am creating a grpc client from .net framework 4.6.2 or 4.8.1 and I am getting the following error when I run the client -

InnerException {"Cannot load file or assembly 'System.Memory, Version=4.0.1.1, Culture =neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The assembly manifest definition does not match the assembly reference (Exception from HRESULT: 0x80131040)":"System.Memory, Version=4.0.1.1, Culture=neutral. , PublicKeyToken=cc7b13ffcd2ddd51"} System.Exception {System.IO.FileLoadException}.

The project that I used as a client is a WCF application but if the client created it in a console application with 4.8.1 as a framework it works correctly there

I install the nuguets
grpc.net.client 2.66.0
google.Protobuf 3.28.3
grpc.tools 2.67.0

code of client
try
{
var channel = GrpcChannel.ForAddress("https://localhost:7104", new GrpcChannelOptions
{
HttpHandler = new WinHttpHandler()
});
var client = new Sap.SapClient(channel);
var reply = client.ProcesarSap(
new SapRequest { Name = "GreeterClient" });
}
catch (Exception ex)
{
string msg = ex.ToString();

}

I create a class library with the client that contains the Proto file and all the nuguets
I create the WCF project and reference the class library with the client.
I run the WCF application in visual studio 2022 and access one of the methods invoking the referenced client, obtaining the described error.

What did you expect to see?

I hope to create a grpc client with .net Framework 4.6.2 or 4.8.1 from a WCF project or asmx service using the grpc.net.client nuguet

Greetings
I hope you can help me

I think your problem is different assembly versions referenced. You probably need binding redirects: https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/redirect-assembly-versions

I found the problem: I had to install the nuguets at the origin of the call as well.
thanks