我们想将我们的项目从 grpc.core 迁移到 gprc-dotnet。在我的 grpc 服务器中,我引用了包 Grpc.AspNetCore。proto 文件在不同的项目中编译并共享。当我实现我的服务器方法时:
**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)
{
...
}
ServerCallContext 类要求我导入要删除的 Grpc.Core。我应该如何使用 grpc-dotnet 来实现我的覆盖,例如 ServerCallContext 类?
看起来 ServerCallContext 是在包含命名空间 Grpc.Core 的包 Grpc.Core.Api 中实现的。这有点令人困惑,但可能是为了向后兼容而实现的。也许有人可以对此发表评论。因此,在这种情况下唯一真正要做的就是使用正确的 nuget 包 Grpc.AspNetCore.Server。对 Grpc.Core 的引用将从这个和底层引用的程序集中提取。