将 Async CTP 与可移植类库一起使用 [英] Using Async CTP with Portable Class Library

查看:31
本文介绍了将 Async CTP 与可移植类库一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将项目重写为可移植类库.但问题是它使用的是异步 CTP,我无法将其编译为 WP 和 Windows Store App 的库.如果我不包含参考 AsyncCtpLibrary.dll,编译器会这样说

I am trying to rewrite a project into a Portable Class Library. But the problem is that it is using Async CTP, and I can't compile it as a library for WP and Windows Store App. If I don't include reference AsyncCtpLibrary.dll, compiler says that

命名空间System.Threading"中不存在类型或命名空间名称Tasks"(您是否缺少程序集引用?)

The type or namespace name 'Tasks' does not exist in the namespace 'System.Threading' (are you missing an assembly reference?)

如果我包含它,编译器仍然会显示相同的错误并添加警告:

If i include it, compiler still says the same errors and adds a warning:

无法解析主要引用AsyncCtpLibrary",因为它间接依赖于框架程序集mscorlib,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089",在当前目标框架中无法解析..NETPortable,版本=v4.0,配置文件=Profile104".要解决此问题,请删除引用AsyncCtpLibrary"或将您的应用程序重新定位到包含mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"的框架版本.

The primary reference "AsyncCtpLibrary" could not be resolved because it has an indirect dependency on the framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETPortable,Version=v4.0,Profile=Profile104". To resolve this problem, either remove the reference "AsyncCtpLibrary" or retarget your application to a framework version which contains "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".

我该如何忍受呢?

推荐答案

简单回答 - AsyncCTP 在 Visual Studio 2012 中不起作用,不能在任何项目中使用.对于 .NET 4.0 和 Silverlight 5,您可以从 NuGet 安装 Async Targeting Pack,它以类似的方式工作.
Async/await 在可移植类库中仅在面向 WinRT、.NET4.5 或 Windows Phone 8 时受支持,即便如此,其使用也非常有限.我不能在这里详细介绍,因为 Windows Phone 8 SDK 仍处于 NDA 之下.
对于 WP7.5 和 VS2012,目前无法使用 async/await,但该平台的更新 Async Targeting Pack 应该会在某个时候可用.
另请注意,AsyncCTP 和 Async Targeting Pack 不能在可移植类库中使用,并且将来不太可能发生变化.结果是在 VS2010 中你不能在 Portable Class Libraries 中使用 async/await.

Simple answer - AsyncCTP is not working in Visual Studio 2012 and cannot be used in any project. For .NET 4.0 and Silverlight 5 you can install Async Targeting Pack from NuGet that works in a similar fashion.
Async/await is in Portable Class Library supported only when targeting WinRT, .NET4.5 or Windows Phone 8 and even then the use is pretty limited. I can't go into more details here, because the Windows Phone 8 SDK is still under NDA.
For WP7.5 and VS2012 there is currently no way how to use async/await, but updated Async Targeting Pack for this platform should be available sometime.
Note also that AsyncCTP and Async Targeting Pack can't be used in Portable Class Libraries and it's unlikely it will change in the future. The result is in VS2010 you cannot use async/await in Portable Class Libraries.

这篇关于将 Async CTP 与可移植类库一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆