“试图读取或写入受保护的内存。这通常表明其他内存已损坏。”
Posted
技术标签:
【中文标题】“试图读取或写入受保护的内存。这通常表明其他内存已损坏。”【英文标题】:"Attempted to read or write protected memory. This is often an indication that other memory is corrupt." 【发布时间】:2010-10-27 09:17:13 【问题描述】:我已经围绕 Unity 构建了一个简单的应用程序框架。 IE。表单和用户控件被描述为 xml 并动态构建。我有一个包含 ComboBox 的表单,当它关闭时会导致下面详述的错误。如果将 ComboBox 替换为 ListBox 控件,则不会出现此问题。
一些谷歌搜索引发了一些关于我无法安装补丁的报告..KB923028
"试图读或写保护 记忆。这通常是一个迹象 其他内存已损坏。"
堆栈跟踪:
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.Control.DefWndProc(Message& m)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ComboBox.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.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(Int32 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)
at System.Windows.Forms.Application.Run(Form mainForm)
at DPOSSQL.Program.Main() in C:\VSSData\DPOS SQL\DPOS SQL\Program.cs:line 46
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
【问题讨论】:
【参考方案1】:当控件使用 XP/Vista 样式,然后在旧版本的 Windows 上运行时,我曾见过这种情况。
【讨论】:
【参考方案2】:我在系统上安装新字体时看到了这个错误。您是否安装了新字体,或者最近安装了新字体的程序?
其他 .net 程序是否正常运行?如果没有,最好的办法可能是重新安装 .NET 框架。
【讨论】:
【参考方案3】:当我的 .NET 应用程序正在运行时,尝试将系统显示切换为“超大字体”时,只需在 Windows XP 上点击此按钮即可。
这似乎与格式错误的字体或类似字体有关。
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source: System.Windows.Forms
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 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)
【讨论】:
以上是关于“试图读取或写入受保护的内存。这通常表明其他内存已损坏。”的主要内容,如果未能解决你的问题,请参考以下文章
System.accessviolationexception 试图读取或写入受保护的内存。这通常表明其他内存已损坏