I am trying to use the following method in a WPF application .NET Framework 4 Client Profile
but I receive this error:
The type or namespace name 'async' could not be found
I am using
using System.Threading.Tasks;
Any idea what could be wrong? Thanks in advance
private async Task SumPageSizesAsync()
{
HttpClient client = new HttpClient();
Task<byte[]> getContentsTask = client.GetByteArrayAsync(url);
byte[] urlContents = await getContentsTask;
}
I am using VS 2010
Well, there are two things:
Microsoft.Bcl.Async
NuGet package to bring in the appropriate library support for .NET 4.In my case the return type was missing, message was cause by code:
private async button1_Click(object sender, EventArgs e)
and should be
private async void button1_Click(object sender, EventArgs e)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With