Cannot find all types required by the async modifier
Asked Answered
F

3

5

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.

Fungosity answered 20/10, 2012 at 9:40 Comment(0)
S
6

You need the Async Targeting Pack to support async in Silverlight 5.

Sandisandidge answered 20/10, 2012 at 10:34 Comment(0)
R
4

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.

Rodmur answered 23/10, 2012 at 16:51 Comment(1)
Why not WP7.1? A project can only target WP7.1 or WP8.0, so supporting only WP7.5+ is useless.Cultured
B
1

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.

Booby answered 20/10, 2012 at 13:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.