如何在.net4.0中使用.net4.5的async/await

一般喜欢学习新技术的同学都用过.net4.5吧,那肯定会被简单、高效的异步编程模型所吸引吧。

去年微软发布了Microsoft.Bcl.Async,该包由三个库组成:Microsoft.Bcl、Microsoft.Bcl.Async和Microsoft.Bcl.Build。

 

 

相关文章可以参考:

Microsoft.Bcl.Async is Now Stable
async 与 await 在 Web 下的应用

 

可能会碰到的问题:

1、出现编译异常

那需要你检查一下各项目中是否都有引用。由于使用了程序集统一的方式,解决方案中的所有工程都必须引用这三个库。

2、使用异常

如果异常信息是“Message : Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)”,

那需要你去微软官网下载.net4.0的KB2468871补丁来安装。

posted on 2014-07-21 09:48  4444  阅读(7319)  评论(5编辑  收藏  举报