Search code examples
c#uwpwin-universal-appclass-library

Async-Call in Universal Windows Class Library


I have a Universal Windows Class Library where I want to call some async methods like:

await Launcher.LaunchUriAsync(new Uri(
    "ms-windows-store://review/?PFN=" + Package.Current.Id.FamilyName));

'IAsyncOperation' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'IAsyncOperation' could be found (are you missing a using directive for 'System'?)

Of course I have System in my using statements:

using System;
using System.Threading.Tasks;
using Windows.System;
using Windows.ApplicationModel;

I suspect I'm missing a reference in my project.json since the only dependency currently in there is

"Microsoft.NETCore.Portable.Compatibility": "1.0.2"

Am I missing a dependency or is this a different issue?


Solution

  • As suspected, I was missing a nuget package, namely Microsoft.NETCore.UniversalWindowsPlatform.

    Seems like this is an issue with the Visual Studio 2017 RC project templates.