赞
踩
严重性 代码 说明 项目 文件 行 禁止显示状态 详细说明
错误 CS5001 程序不包含适合于入口点的静态 “Main” 方法 GrpcGreeterClient F:\Users\invengo\source\repos\GrpcGreeterClient\CSC 1 活动 程序不包含适合于入口点的静态 “Main” 方法
static async void Main(string[] args)
{
// The port number must match the port of the gRPC server.
using var channel = GrpcChannel.ForAddress("https://localhost:7232");
var client = new Greeter.GreeterClient(channel);
var reply = await client.SayHelloAsync(
new HelloRequest { Name = "GreeterClient" });
Console.WriteLine("Greeting: " + reply.Message);
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
在Main方法中使用await调用异步方法,报错
修改为:
static async Task Main(string[] args)
编译通过,问题解决。
static async Task Main(string[] args)
{
// The port number must match the port of the gRPC server.
using var channel = GrpcChannel.ForAddress("https://localhost:7232");
var client = new Greeter.GreeterClient(channel);
var reply = await client.SayHelloAsync(
new HelloRequest { Name = "GreeterClient" });
Console.WriteLine("Greeting: " + reply.Message);
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。