I get the following two compiler errors (Resharper 7.0.1 reports no errors):
Predefined type 'System.Runtime.CompilerServices.IAsyncStateMachine' is not defined or imported
Cannot find all types required by the 'async' modifier. Are you targeting the wrong framework version, or missing a reference to an assembly?
but this code will not compile:
public class Class1
{
public Class1()
{
Um();
}
public async Task<DownloadStringCompletedEventArgs> Um()
{
var client = new WebClient();
return await Observable.FromEvent<DownloadStringCompletedEventHandler, DownloadStringCompletedEventArgs>(x => client.DownloadStringCompleted = x,
x => client.DownloadStringCompleted -= x);
}
}
I've seen MSBuild doesn't find async required references already except that I have VS 2012 NOT VS 11 Beta - although it was installed. Also I tried it in a brand new assembly, no xaml namespace pointing to the application.
CodePudding user response:
You need the Async Targeting Pack to support async
in Silverlight 5.
CodePudding user response:
We just released a beta of Async for .NET Framework 4, Silverlight 4 and 5, and Windows Phone 7.5: http://blogs.msdn.com/b/bclteam/archive/2012/10/22/using-async-await-without-net-framework-4-5.aspx.
CodePudding user response:
You cannot use AsyncCTP in Visual Studio 2012. You can use Async Targeting Pack (available on NuGet) for Silverlight 5. No solution is yet available for Silverlight 4, not sure if there will be any.