3

We want to migrate our project from grpc.core to gprc-dotnet. In my grpc server I reference the packages Grpc.AspNetCore. The proto file is compiled in a different project and shared. When I implement my server method like:

**using Grpc.Core;**
using Sample.Shared;

namespace Sample.GrpcServer.Services;

public class CustomerService : CustomerGrpcService.CustomerGrpcServiceBase
{
    private readonly ILogger<CustomerService> _logger;
    public CustomerService(ILogger<CustomerService> logger)
    {
        _logger = logger;
    }

    public override Task<CustomerListResponse> GetCustomerList(CustomerListRequest request, ServerCallContext context)
    {
       ...
    }

The ServerCallContext class requires me to import Grpc.Core which I want to remove. How am I supposed to use grpc-dotnet to implement my overrides eg the ServerCallContext class?

It looks like ServerCallContext is implemented in the package Grpc.Core.Api which contains the namespace Grpc.Core. This is a little confusing but was probably implemented for backward compatibiliy. Perhaps somebody can comment on that. So the only thing really to do in this scenario is to use the correct nuget package Grpc.AspNetCore.Server. References to Grpc.Core will be pulled from this and underlying referenced assembly.

  • Hey, did you find any solution for this ? – Fabian Rodriguez Feb 03 '22 at 01:12
  • @Fabian I did a package analysis of the Grpc.AspNetCore package and found that it uses the same namespace (Grpc.Core) as the deprecated Grpc.Core package. So in fact for us, there was nothing to do but remove the references to the deprecated packages. In fact the Grpc.AspNetCore package also contains the Google.Protobuf and Grpc.Tools package so those don't have to be referenced either. – Thomas Möchel Feb 04 '22 at 14:35

1 Answers1

0

Grpc.AspNetCore packages contains a namespace Grpc.Core with classes like ServerCallContext that also were in the deprecated Grpc.Core package.

We removed the references to the deprecated packages Grpc.Core and also removed references to Google.Protobuf and Grpc.Tools since they are included in Grpc.AspNetCore package.

This link provides additional information on grpc migration: https://learn.microsoft.com/en-us/aspnet/core/grpc/migration?view=aspnetcore-6.0

mybrave
  • 1,662
  • 3
  • 20
  • 37