c# - 访问冲突:试图读取或写入受保护的内存。这通常表明其他内存已损坏
问题描述
尝试过:Treeview 控件从一个节点移动到另一个节点时面临访问冲突问题,有时会发生行为不一致,有时不会。10 次中有 2 次我们看到异常。
环境:Windows 10 64 位,VS2017 4.6.1 框架。
堆栈跟踪:消息:尝试读取或写入受保护的内存。这通常表明其他内存已损坏。
堆栈跟踪:
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.TreeView.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.TreeView.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
解决方案
推荐阅读
- ruby - PowerShell:功能:reduce:如何初始化reduce累加器?
- android - 如何从 Android 10 中的 MediaStore 获取 MediaMetaData,如专辑、曲目、标题、专辑封面等
- vue.js - 响应式图表不受控制地增长
- javascript - jQuery/CreateJS $.ajax“位图未定义”
- python - 如何使用任何按键触发命令
- r - “对比只能应用于具有 2 个或更多水平的因素”尽管每个因素都有多个水平
- delphi - 将对象方法添加到字符串列表,以便可以按名称调用它们
- rust - 如何将现有的货物二进制文件转换为库
- terraform - 如何使用 terraform 和 localstack 制作 aws_cloudwatch_event_rule?
- java - 使用 Tor 浏览器:使用 SOCKS 代理时如何获取 IP 地址