如何在 Windows uwp 应用程序上使用 Iot.Device.Bindings nuget 包?

How to use Iot.Device.Bindings nuget package on Windows uwp app?

我的树莓派(windows 10 物联网核心)上有 Windows UWP 前台应用程序 运行。我想使用 Iot.Device.Bindings nuget 包从各种传感器(例如 bme680)捕获数据。但看起来这个包在 UWP 上不受支持:

NU1202: Package Iot.Device.Bindings 1.2.0 is not compatible with uap10.0.17763 (UAP,Version=v10.0.17763). Package Iot.Device.Bindings 1.2.0 supports:
  - net5.0 (.NETCoreApp,Version=v5.0)

我尝试为 iot 核心创建后台作业,但出现同样的错误。 有人可以建议如何实现这一目标吗? 提前致谢!

是的,Iot.Device.Bindings 包不支持 Windows IoT Core 上的 UWP,但适用于 .net Core。由于库在命名空间 System.Decive. 中使用 APIs。对于 UWP 应用程序,您需要在命名空间 Windows.Device. 中使用 APIs。目前,我找不到为各种传感器实现的包。这里有两个建议:

  1. 创建一个使用 Iot.Device.Bindings nuget 包的 .net 核心应用程序,并构建一个通道以将数据从 .net 核心应用程序发送到您的 UWP 应用程序,例如 tcp 或 web API.
  2. 参考源码实现UWP库