【发布时间】:2021-07-12 12:24:37
【问题描述】:
我正在尝试将功能从 UWP example for BLE 分离到单独的库中进行测试。
我成功地将其设置为独立的测试库(使用 netcore 3.0)
但是,在迁移到我的 GUI 应用程序(现在使用 netcore 5.0)时,无法再引用 WinRT,因此我不得不删除对 Windows 合同的引用。
现在我正在运行并且能够找到我的 BLE 设备(甚至是正确的读/写特征),但是现在当我写入设备特征时,我遇到了 NullReferenceException 的破坏性崩溃。
所涉及对象中的所有变量似乎都不为空,除了 Gatt 特性中的设备 ID 隐藏了互操作 COM 异常,但是,这对于我在 3.0 中的“控制台应用程序”也是如此,它没有这个问题并且工作正常(即使存在相同的条件)
如何进行更深入的调试?这是一个安全问题吗?
我的目标是 net5.0-windows10.0.19041
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=System.Private.CoreLib
StackTrace:
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Library.BleLib.BleComms.<WriteBufferToSelectedCharacteristicAsync>d__21.MoveNext() in C:\Testing\Net\trunk\Externals\BleLib\BleComms.cs:line 200
【问题讨论】:
标签: c# uwp bluetooth-lowenergy gatt