c# – 将Async CTP与可移植类库一起使用

c# – 将Async CTP与可移植类库一起使用,第1张

概述我试图将项目重写为可移植类库.但问题是它使用的是Async CTP,我无法将其编译为WP和 Windows Store App的库.如果我不包含引用AsyncCtpLibrary.dll,编译器会说 The type or namespace name ‘Tasks’ does not exist in the namespace ‘System.Threading’ (are you missi 我试图将项目重写为可移植类库.但问题是它使用的是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,PublicKeyToken=b77a5c561934e089”.

我该怎么忍受?

解决方法 简单回答 – AsyncCTP在Visual Studio 2012中不起作用,不能在任何项目中使用.对于.NET 4.0和Silverlight 5,您可以从NuGet安装以类似方式工作的Async targeting Pack. 只有在针对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. 总结

以上是内存溢出为你收集整理的c# – 将Async CTP与可移植类库一起使用全部内容,希望文章能够帮你解决c# – 将Async CTP与可移植类库一起使用所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1248358.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-07
下一篇2022-06-07

发表评论

登录后才能评论

评论列表(0条)

    保存