【问题标题】:AccessViolationException from DeviceWatcher.GetBackgroundTrigger来自 DeviceWatcher.GetBackgroundTrigger 的 AccessViolationException
【发布时间】:2018-02-27 11:20:41
【问题描述】:

有时(尽管很少)我会从以下代码行中得到 System.AccessViolationException

var background = deviceWatcher.GetBackgroundTrigger(new List<DeviceWatcherEventKind> { DeviceWatcherEventKind.Add, DeviceWatcherEventKind.Remove, DeviceWatcherEventKind.Update });

System.AccessViolationException
HResult=0x80004003
Message=试图读取或写入受保护的内存。这通常表明其他内存已损坏。

我应该做些什么来防止这个异常?

【问题讨论】:

    标签: uwp bluetooth-lowenergy


    【解决方案1】:

    由于您的问题不是 100% 重现,因此我们无法重现您的问题。所以这不应该是代码问题。

    实际上这个问题不应该发生在托管代码中。您可以尝试设置 Visual Studio 调试器以绕过此异常:

    Tools menu ->Options -> Debugging -> General -> 取消勾选“Suppress JIT optimization on module load”

    更多细节你可以参考这个similar thread

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-26
      • 2017-01-17
      相关资源
      最近更新 更多