I got Async private method that call 3rd party WCF service and in return it get string value. I have added await to the WCF call but getting error
'string' does not contain a definition for GetAwaiter and no accessible extension method accepting first argument of type string
private async Task<string> InitializeCall()
{
string response = string.Empty;
response = await eziClient.GetTransactionsAsync(username, "", BatchNumber.ToString(), "").GetAwaiter().GetResult();
return response;
}
not sure what I missing here?
Remove .GetAwaiter().GetResult()
:
private async Task<string> InitializeCall()
{
string response = string.Empty;
response = await eziClient.GetTransactionsAsync(username, "", BatchNumber.ToString(), "");
return response;
}
The result of .GetAwaiter().GetResult()
was a string
, and you can't await
a string
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.