代码之家  ›  专栏  ›  技术社区  ›  xmedeko

Windows UWP BLE DeviceInformation.CreateWatcher抛出属性键语法错误

  •  0
  • xmedeko  · 技术社区  · 6 年前

    我们有一个桌面Windows应用程序使用一些UWP蓝牙LE-UWP功能。我们启动观察程序:

    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设置?

    1 回复  |  直到 6 年前
        1
  •  0
  •   DerekGn    6 年前

    我在windows WPF桌面应用程序中看到过此异常。原因是我忽略了检测到Windows 10的版本比1703aka creators版本大。因此,在早期版本的Windows 10上运行应用程序的任何人都会看到此错误。不幸的是,错误是如此模糊,不支持的错误会更好。

    推荐文章