xNiux
xNiux

Reputation: 181

BLE GATT in UWP application : Problem with async functions

I'm working on UWP Application to manage a BLE / GATT device. I'm following the official documentation from Microsoft (https://learn.microsoft.com/fr-fr/windows/uwp/devices-sensors/gatt-client). But I have a problem with the async function from BluetoothLEDevice class.

When I write the following line :

BluetoothLEDevice bluetoothLeDevice = await BluetoothLEDevice.FromIdAsync(deviceInfo.Id);

I have the followings errors :

Because sometimes, it is more readable

I tried to add manually the following reference (Like I found in multiple post) :

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v4.5\system.runtime.windowsruntime.dll

C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd

But, in the first case, VS saying it is already including by the generator system (or someting like this). And in the 2nd case, I have many class in my code that are referenced twice (Like Page for example)

What is the solution ?

Upvotes: 1

Views: 414

Answers (1)

JonasH
JonasH

Reputation: 36596

My guess is that you lack references to the UWP api that is needed to use it in .Net applications.

Make sure you are using Package References in your project and you have added Microsoft.Windows.SDK.Contracts as a nuget package

Upvotes: 1

Related Questions