来自组合的AccessViolationException:尝试读取或写入受保护的内存 [英] AccessViolationException from a combo: Attempted to read or write protected memory

查看:866
本文介绍了来自组合的AccessViolationException:尝试读取或写入受保护的内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用我们的应用程序(VB.Net,Winforms,使用框架的v2)时,用户偶尔会遇到上述错误。我无法重现它。调用堆栈如下:

Users are occassionally getting the above error when using our application (VB.Net, Winforms, using v2 of the framework). I'm not able to reproduce it. The callstack is as follows:

:System.AccessViolationException:尝试读取或写入受保护的内存。这通常表明其他内存已损坏。
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc,IntPtr hWnd,Int32 msg,IntPtr wParam,IntPtr lParam)
在System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
在System.Windows.Forms.Control.WndProc(Message& m)
在System.Windows.Forms.ComboBox。 System.Windows上的System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
处的ControlEx.AutoCompleteCombo.WndProc(Message& m)
中的WndProc(Message& m)
.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)

: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. 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.WndProc(Message& m) at System.Windows.Forms.ComboBox.WndProc(Message& m) at ControlEx.AutoCompleteCombo.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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

ControlEx.AutoCompleteCombo.WndProc的代码如下:

The code for ControlEx.AutoCompleteCombo.WndProc is as follows:

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
    Try
        If Not m_fReadOnly Then
            MyBase.WndProc(m)
        Else
            Select Case m.Msg
                Case WM_LBUTTONDOWN, WM_LBUTTONDBLCLK
                    ' do nothing
                Case Else
                    MyBase.WndProc(m)
            End Select
        End If
    Catch ex As OutOfMemoryException
        Throw New OutOfMemoryException("Exception during WndProc for combo " & Me.Name, ex)
    End Try
End Sub

错误处理添加,所以我们可以确定当我们得到一个OutOfMemoryException时,哪个组合导致的问题。

The error handling was added so we can determine which combo causes the problem when we get an OutOfMemoryException.

任何线索,什么原因,将非常感谢! : - )

Any clues as to what causes this would be muchly appreciated! :-)

推荐答案

我在代码中有一个奇怪的非确定性的OutOfMemoryException。

I have a strange non-deterministic feeling with the OutOfMemoryException in your code.

你为什么需要?如果你需要它,这可能是你的问题的原因? OutOfMemoryExceptions是非常罕见的。如果你有这些,我会认为这是一个强烈的迹象,其他的错误。

Why do you need that? And if you need it, may this be the cause of your problems? OutOfMemoryExceptions are very rare. If you have these, I would think it is a strong indication something else is wrong.

这篇关于来自组合的AccessViolationException:尝试读取或写入受保护的内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆