';等待&x27;运算符只能在带有c#异常的异步方法中使用?

';等待&x27;运算符只能在带有c#异常的异步方法中使用?,c#,asp.net,.net,C#,Asp.net,.net,我正在使用hellosign c#api,当我使用下面的代码调用帐户信息函数时 var helloSign = new HelloSignClient("username", "password"); Account account = await helloSign.Account.GetAsync(); Console.WriteLine("Your current callback: " + account.CallbackUrl); 我正在犯错误 Error 2

我正在使用hellosign c#api,当我使用下面的代码调用帐户信息函数时

var helloSign = new HelloSignClient("username", "password");
    Account account = await helloSign.Account.GetAsync();
    Console.WriteLine("Your current callback: " + account.CallbackUrl);
我正在犯错误

Error    2    The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'.
下面是GetAsync方法

public async Task<Account> GetAsync()
        {
            AccountWrapper accountWrapper = await helloSignService.MakeRequestAsync<AccountWrapper>(settings.HelloSignSettings.Endpoints.Account.Get);
            return accountWrapper.Account;
        }

有人能告诉我如何调用它或如何调试它吗?

您只能在异步方法中使用wait


同样的问题还有一个问题

信息非常清楚。此行必须位于标有
async
的方法内:

Account account = await helloSign.Account.GetAsync();

您应该像这样用异步方法包装这个块

public async Task<Type> MethodAsync(){
    // other code if needed ....
    var helloSign = new HelloSignClient("username", "password");
    Account account = await helloSign.Account.GetAsync();
    Console.WriteLine("Your current callback: " + account.CallbackUrl);
    return type;

}
public async Task MethodAsync(){
//其他代码(如果需要…)。。。。
var helloSign=新的HelloSignClient(“用户名”、“密码”);
Account Account=等待helloSign.Account.GetAsync();
WriteLine(“您当前的回调:+account.CallbackUrl”);
返回类型;
}

最近签名有变化吗-你能尝试一个干净的版本吗?@DanielA.White我已经重建了。。但是不工作。。。所以我想发布它..@DanielA.White最近签名更改意味着什么…??如果我想返回一些类型,我应该如何调用main方法内部。。我该怎么做你能给我解释一下吗??
public async Task<Type> MethodAsync(){
    // other code if needed ....
    var helloSign = new HelloSignClient("username", "password");
    Account account = await helloSign.Account.GetAsync();
    Console.WriteLine("Your current callback: " + account.CallbackUrl);
    return type;

}