-1

I have followed this microsoft tutorial to create gRPC service and client. Now i have problem with generating gRPC client class.

To get data i use this method, but i doesn't seem right. I wish I could inject client using AddGrpcClient but i can't find any generated client gRPC classes.

using var channel = GrpcChannel.ForAddress("http://localhost:5053");
var client = channel.CreateGrpcService<IFullProjectInfoService>();

var reply = await client.GetFullProjectInfoAsync(
    new FullProjectInfoRequest { ProjectId = 1, UserId = 1 }
);

1 Answer 1

0

To inject the client using dependency injection, you could use the AddCodeFirstGrpcClient function, as it is documented in the Register client service section of protobuf.net.

For your example it would look something like:

services.AddCodeFirstGrpcClient<IFullProjectInfoService>(o =>
{
    o.Address = new Uri("http://localhost:5053");
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.