带有async await &.IsValueType方法()
本文关键字:方法 IsValueType async await 带有 | 更新日期: 2023-09-27 18:02:41
我需要在同一个可移植类库中实现以下调用:
public class Foobar
{
void Foo()
{
var b = GetType().IsValueType; //<-- 2
}
async Task<IEnumerable<T>> Bar<T>()
where T : class, IBaz, new()
{
return await Task.Factory.StartNew(() => new List<T>(new[] //<-- 1
{
new T {Qux = Guid.NewGuid().ToString()}
}));
}
interface IBaz
{
string Qux { get; set; }
}
}
设置以下目标框架:
- .net Framework 4.5
- Sliverlight 5
- Windows Phone 8 .Net for Windows Store apps
我得到这个构建错误:
无法找到'async'修饰符所需的所有类型。您的目标是错误的框架版本,还是缺少对程序集的引用?
我尝试安装bcl,但仍然得到相同的错误。如果我删除Sliverlight目标异步工作但然后我失去了类型类的IsValueType prop。
您需要安装Microsoft.Bcl.Async.