How do I configure a WPF project to use BLE?

4

Update 2: Below are the details of where I am at the moment, but I didn't want the detail to derail any general answers that may bear on the base question of finding any path to BLE / GATT in WPF.

Build system version:

Microsoft Visual Studio Community 2017 
Version 15.7.4
VisualStudio.15.Release/15.7.4+27703.2035
Microsoft .NET Framework
Version 4.7.03056

So far, I have changed the project file to target windows 8.1, <TargetPlatformVersion>8.1</TargetPlatformVersion>.

Currently, I am getting local BLE advertisements, but when I try to access a GATT service:

var _service = await GattDeviceService.FromIdAsync(deviceId);

I get the following error:

System.BadImageFormatException
  HResult=0x80131058
  Message=Could not load file or assembly 'System.Runtime.WindowsRuntime, Version=4.0.10.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies.
Reference assemblies should not be loaded for execution.  They can only be loaded in
the Reflection-only loader context. (Exception from HRESULT: 0x80131058)

Inner Exception 1:
BadImageFormatException: Cannot load a reference assembly for execution.

Also, I noticed that the following DLL is not on my system and that also seems like a problem (that I have also not been able to solve so far):

"Windows.Devices.Bluetooth.GenericAttributeProfile.dll"

Update 1: I have attempted to include WinRT. Here is my Reference and it's properties:

Reference Properties

Any help will be greatly appreciated.

c#
bluetooth
bluetooth-lowenergy
gatt
asked on Stack Overflow Oct 10, 2018 by Sean Vikoren • edited Oct 16, 2018 by Sean Vikoren

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0