Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何配置WPF项目以使用BLE?_C#_Bluetooth_Bluetooth Lowenergy_Gatt - Fatal编程技术网

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

C# 如何配置WPF项目以使用BLE?,c#,bluetooth,bluetooth-lowenergy,gatt,C#,Bluetooth,Bluetooth Lowenergy,Gatt,更新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,8.1 目前,

更新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,
8.1

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

var _service = await GattDeviceService.FromIdAsync(deviceId);
更新1: 我已尝试将WinRT包括在内。 以下是我的参考资料及其属性:

非常感谢您的帮助。

安装

然后为以下内容添加三个参考:

Windows
Windows.Foundation.FoundationContract
WindowsBase
然后在属性中将“复制本地”设置为“true”

可能的位置提示:

D:\Windows Kits\10\UnionMetadata\10.0.17134.0\Windows.winmd
D:\Windows Kits\10\References\10.0.17134.0\Windows.Foundation.FoundationContract\3.0.0.0\en\Windows.Foundation.FoundationContract.xml
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\WindowsBase.dll
确保在目标计算机上执行完整更新。在撰写本文时,有一些项目在Win10更新完成之前无法正常工作


另一种可能的方法是通过NuGet,尽管我从未有机会尝试过。

事实上WinRT根本没有这样的dll。可能你引用了一些错误的东西。您是否使用WinMD导入了WinRT?@MikePetrichenko我已在上面进行了更新。这回答了你的问题吗?看来你必须参考一些其他文件:@MikePetrichenko谢谢你的链接。我将完成说明并尽快回复您。我的印象是,GATT for BLE在Win10之前不可用,甚至一开始也不可用(创建者更新,2017年)。看见注意,LE外设支持GATT客户端模式。哦,正如@MikePetrichenko所指出的,WPF不会直接做BLE。我错过什么了吗?