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
To await an IAsyncOperation
, you need two things:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll
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.
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);