首页 > 解决方案 > 访问冲突:试图读取或写入受保护的内存。这通常表明其他内存已损坏

问题描述

尝试过: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)

标签: c#.netwindowswinforms

解决方案


推荐阅读