类型或命名空间名称“异步”找不到 [英] The type or namespace name 'async' could not be found
本文介绍了类型或命名空间名称“异步”找不到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用下面的方法在WPF应用程序 .NET Framework 4的客户端配置文件
但我收到此错误:
I am trying to use the following method in a WPF application .NET Framework 4 Client Profile
but I receive this error:
的类型或命名空间名称异步无法找到的
我使用
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;
}
我使用VS 2010
I am using VS 2010
推荐答案
那么,有两件事情:
- 您需使用C#编译器5,例如VS2012。如果你使用VS2010,您不能使用异步。鉴于此错误信息,我怀疑你使用了错误的编译器版本。
- 您需要使用
Microsoft.Bcl.Async
的NuGet包带来的.NET 4的相应的库支持。
这篇关于类型或命名空间名称“异步”找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文