0

I'm not a Windows/Visual Studio person, so maybe I'm doing something obviously wrong. I'm going to have to write a gRPC wrapper around a library for .NET 4.8. That means I won't be able to use the newer grpc-dotnet and should use the older Grpc.Core library.

As far as I can tell, I need to manually generate the C# code using protoc, so I'm using this command:

protoc --proto_path=. --csharp_out=grpc .\greet.proto --grpc_out=grpc --plugin=protoc-gen-grpc="C:\users\foo\.nuget\packages\grpc.tools0円.5.0\tools\grpc_csharp_plugin.exe"

I get two files Greet.cs and GreetGrpc.cs which I add to my Visual Studio project. I've also added some nuggets I thought are relevant (Google.Protobuf, Grpc.Core, Grpc.Tools, Grpc.Net.Client). The generated code does not compile though.

For example this line:

static readonly Marshaller<global::Greet.HelloRequest> __Marshaller_HelloRequest = Marshallers.Create((arg) => arg.ToByteArray(), global::Greet.HelloRequest.ParseFrom);

would cause an error:

'HelloRequest' does not contain a definition for 'ParseFrom'

Also this line:

static readonly Method<global::Greet.PrepareRequest, global::Greet.PrepareResponse> __Method_Prepare = new Method<global::Greet.PrepareRequest, global::Greet.PrepareResponse>(
 MethodType.Unary,
 "Prepare",
 __Marshaller_PrepareRequest,
 __Marshaller_PrepareResponse);

causes:

There is no argument given that corresponds to the required parameter 'responseMarshaller' of 'Method<PrepareRequest, PrepareResponse>.Method(MethodType, string, string, Marshaller, Marshaller)'

I would appreciate any help.

Olivier Jacot-Descombes
114k14 gold badges149 silver badges202 bronze badges
asked Dec 24, 2024 at 12:11
9
  • ".nuget\packages\grpc.tools0円.5.0"! Is that actually the 0.5.0 version of GRPC Tools from 2015? I would seriously consider updating that to something a bit more recent. Commented Dec 24, 2024 at 12:16
  • Looking at Visual Studio, the installed version is 2.68.1. I think I should poke around to see where that resides in the file system. Commented Dec 24, 2024 at 12:23
  • Yeah, if you have a later version installed you should try updating the --plugin=protoc-gen-grpc= option to refer to a later version. Commented Dec 24, 2024 at 12:43
  • @phuzi I can't seem to find the newer version. Neither Windows Search nor google is being helpful. Can you tell me where I can download the latest version of that plugin? Commented Dec 24, 2024 at 12:44
  • 1
    Found it. For some reason, I thought there's no other version in that directly, but there is one. Update to the latest version, and it's fixed. Thanks a lot! Commented Dec 24, 2024 at 12:50

1 Answer 1

1

Your protoc command appears to be using an ancient version of the csharp grpc plugin that was released way back in 2015! I would guarantee that the generated C# has come a long way since then.

--plugin=protoc-gen-grpc="C:\users\foo\.nuget\packages\grpc.tools0円.5.0\tools\grpc_csharp_plugin.exe"

You've stated in the comments that the project/solution is using the latest version (currently 2.68.1). You should update the --plugin=protoc-gen-grpc= option to refer to the installed version so that the generated C# code is in-sync with the installed GRPC.Core package.

C:\users\foo\.nuget\packages\grpc.tools2円.68.1 directory.

answered Dec 24, 2024 at 12:54
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.