如何配置 WPF 项目以使用 BLE?

How do I configure a WPF project to use BLE?

更新 2: 以下是我目前所处位置的详细信息,但我不希望这些细节破坏任何可能与在 WPF 中找到通往 BLE / GATT 的任何路径的基本问题有关的一般性答案。

构建系统版本:

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

到目前为止,我已经将项目文件更改为目标 windows 8.1,<TargetPlatformVersion>8.1</TargetPlatformVersion>

目前,我收到本地 BLE 广告,但当我尝试访问 GATT 服务时:

var _service = await GattDeviceService.FromIdAsync(deviceId);

更新 1: 我试图包括 WinRT。 这是我的参考及其属性:

任何帮助将不胜感激。

安装 Windows 10 SDK.

然后添加三个引用:

Windows
Windows.Foundation.FoundationContract
WindowsBase

然后在属性中将'Copy Local'设置为'true'。

可能的位置提示:

D:\Windows Kits\UnionMetadata.0.17134.0\Windows.winmd
D:\Windows Kits\References.0.17134.0\Windows.Foundation.FoundationContract.0.0.0\en\Windows.Foundation.FoundationContract.xml
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\WindowsBase.dll

一定要在目标机器上进行全面更新。在撰写本文时,有一些项目在 Win10 更新完成之前无法正常工作。

另一种可能的方法是通过 NuGet UWP-Desktop,尽管我一直没有机会尝试。