static void Main(string[] args) { //1、建立连接 //GrpcChannel grpcChannel = GrpcChannel.ForAddress("https://localhost:5002"); //// 2、客户端创建 //GreeterClient greeterClient = new Greeter.GreeterClient(grpcChannel); ////// 3、开始调用 //HelloReply helloReply = greeterClient.SayHello(new HelloRequest() //{ // Name = "grpc客户端" //}); //// 3、开始调用 //GetUserListResp resp = greeterClient.GetUserList(new GetUserListReq() //{ // Name = "GetUserList" //}); //// 4、打印 //Console.WriteLine($"返回值打印:1:{helloReply.Message};2:{resp.UserListInfo}"); //grpcChannel.Dispose(); using (GrpcChannel grpcChannel = GrpcChannel.ForAddress("https://localhost:5002")) { // 2、客户端创建 GreeterClient greeterClient = new Greeter.GreeterClient(grpcChannel); //// 3、开始调用 HelloReply helloReply = greeterClient.SayHello(new HelloRequest() { Name = "grpc客户端" }); // 3、开始调用 GetUserListResp resp = greeterClient.GetUserList(new GetUserListReq() { Name = "GetUserList" }); // 4、打印 Console.WriteLine($"返回值打印:1:{helloReply.Message};2:{resp.UserListInfo}"); } }