FromBluetoothAddressAsync IAsyncOperation does not contain a definition for 'GetAwaiter' error

前端 未结 2 683
隐瞒了意图╮
隐瞒了意图╮ 2020-11-29 09:53

I am working on a simple BLE UWP. I\'ve been referring to \"Windows UWP connect to BLE device after discovery\", working in Visual Studio 2017.

The core code I have

相关标签:
2条回答
  • 2020-11-29 10:03

    To await an IAsyncOperation, you need two things:

    • A reference to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll
    • A reference to C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Facade\Windows.WinMD

    If either reference is missing then it won't work. You can also use the UwpDesktop nuget package, that will do the work for you.

    Note: specifically GetAwaiter is extension in System namespace that is available from those references (you still need using System; - make sure you have not removed it from the file). The extension info is on MSDN - WindowsRuntimeSystemExtensions.GetAwaiter.

    0 讨论(0)
  • 2020-11-29 10:18

    For some of the other UWP operations just add using System:

    using System;
    
    //...
    
    // example - getting file reference:
    var file = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync("myFile.txt);
    
    0 讨论(0)
提交回复
热议问题