Using Async CTP with the Portable Class Library

I am trying to rewrite a project in a portable class library. But the problem is that it uses Async CTP, and I can not compile it as a library for WP and Windows Store App. If I do not include the AsyncCtpLibrary.dll link, the compiler says that

The type or name of the Tasks namespace does not exist in the System.Threading namespace (do you miss the assembly reference?)

If I turned it on, the compiler still says the same errors and adds a warning:

The main link "AsyncCtpLibrary" cannot be resolved, since it has an indirect dependence on the frame assembly "mscorlib, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089", which cannot be resolved in the target environment, ".NETPortable, Version = v4.0, profile = Profile104 ". To fix this problem, either remove the AsyncCtpLibrary link or migrate the application to the framework version that contains mscorlib, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089.

How can I handle this?

+6
source share
3 answers

Simple answer. AsyncCTP does not work in Visual Studio 2012 and cannot be used in any project. For .NET 4.0 and Silverlight 5, you can install the Async Targeting Pack from NuGet, which works the same way.
Async / await is in a portable class library that is only supported when targeting WinRT, .NET4.5, or Windows Phone 8, and even then usage is quite limited. I cannot go into details here because the Windows Phone 8 SDK is still under the NDA.
There is currently no way to use async / await for WP7.5 and VS2012, but the updated Async Targeting Pack for this platform should be available sometime.
Also note that AsyncCTP and Async Targeting Pack cannot be used in portable class libraries, and this is unlikely to change in the future. In VS2010, you cannot use async / wait in portable class libraries.

+3
source

Currently, you can use async / wait portable when you plan to use the .NET 4.5 and Window Store applications. Outside the laptop, you can use the Async targeting package for .NET 4.0 and Silverlight 5.

Talking about the fact that we are working on an updated asynchronous targeting package that adds async / wait support in a portable application when configured on Phone 7.5, Silverlight 5 and .NET 4.0, see http://visualstudio.uservoice.com/forums/121579 -visual-studio / suggestions / 2691068-support-async-in-portable-class-libraries . You will see this in early October.

Update . We just released a beta version of this: http://blogs.msdn.com/b/bclteam/archive/2012/10/22/using-async-await-without-net-framework-4-5.aspx .

+5
source

You can try using the AsyncBridge project instead of AsyncCTP. I do not know if this will help. You will need to compile in VS2012 for this to work (you can still target to .NET4.0):

+1
source

All Articles