c# - 将异步 CTP 与可移植类库一起使用

标签 c# windows-8 windows-phone async-ctp portable-class-library

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

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

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

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".

我该如何忍受?

最佳答案

当前,当面向 .NET 4.5 和 Window Store 应用程序时,您只能在可移植应用程序中使用 async/await。在可移植之外,您可以使用适用于 .NET 4.0 和 Silverlight 5 的 Async Targeting Pack。

尽管如此,我们正在开发一个更新的异步目标包,它在面向 Phone 7.5、Silverlight 5 和 .NET 4.0 时增加了对可移植异步/等待的支持,请参阅:http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2691068-support-async-in-portable-class-libraries .您将在 10 月初看到。

更新:我们刚刚发布了测试版:http://blogs.msdn.com/b/bclteam/archive/2012/10/22/using-async-await-without-net-framework-4-5.aspx .

关于c# - 将异步 CTP 与可移植类库一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12597797/

相关文章:

c# - 如何将 C# 变量声明为 HTML 类型变量?

javascript - ASP.NET Core SPA 中基于 JWT 的身份验证 - 前端验证

c# - 如何在用 c#/XAML 开发的 Windows 商店应用程序中的 SQLite 中插入 blob

windows-phone-8 - Windows Phone - 序列化/保存 InkPresenter 控件

c# - 可供 Windows Phone 开发人员使用的传感器命名空间之间有什么区别?

c# - 使用 DllImport 在 C# 中调用 OpenGL 函数?

c# - 线程循环,以最佳方式关闭它

networking - Windows Phone 8 模拟器无法连接到互联网

http-post - 如何在 Windows 8 Metro 中执行 post 方法?

caching - 寻求 Akavache 文档或示例