c# - Windows UWP BLE DeviceInformation.CreateWatcher 抛出属性键语法错误
问题描述
我们有一个使用一些 UWP 蓝牙 LE UWP 功能的桌面 Windows 应用程序。我们启动观察者:
string BTLEDeviceWatcherAQSString = "(System.Devices.Aep.ProtocolId:=\"{bb7bb05e-5972-42b5-94fc-76eaa7084d49}\")";
string[] props = { "System.Devices.Aep.DeviceAddress", "System.Devices.Aep.IsConnected", "System.Devices.Aep.Bluetooth.Le.IsConnectable"};
watcher = DeviceInformation.CreateWatcher(BTLEDeviceWatcherAQSString, props, DeviceInformationKind.AssociationEndpoint);
它在大多数机器上运行良好,只是我们很少有匿名错误日志:
System.Exception: Element not found. Property key syntax error. A property key must either be specified as a canonical property name (preferred) or be of the form {fmtid} pid.
at Windows.Devices.Enumeration.DeviceInformation.CreateWatcher(String aqsFilter, IEnumerable`1 additionalProperties, DeviceInformationKind kind)
我们为 Windows 10.0.15063(即 1703)或更高版本运行此代码,因此所有属性都应由 doc 提供。
什么可能导致此错误?一些硬件配置或 Windows 10 设置?
解决方案
我在 Windows WPF 桌面应用程序中看到了这个异常。原因是我忽略了检测到 Windows 10 的修订版大于 1703 版 AKA 创作者版。因此,在早期版本的 Windows 10 上运行该应用程序的任何人都会看到此错误。不幸的是,错误是如此模糊,不支持的错误会更好。
推荐阅读
- javascript - html 404 中的 node.js javascript 文件
- c++ - Eigen:: 无法转换 Block
参考 当列数固定时 - ruby-on-rails - Rails 主动存储,未经允许的参数
- python - 旋转 Geoplot 多图
- mimekit - mimekit 可以将加密的 .msg 文件保存为未加密的 .msg 文件吗?
- javascript - 用 jquery 覆盖 ctrl-arrows
- c# - 使用动态属性名称反序列化 json
- python - 如何根据 PyQt5 中另一个 Combo Box 中选择的值更新一个 Combo Box 的内容
- flutter - 如何在颤动中增加文本字段标签大小(宽度)?
- node.js - Node.js HEAD http 请求