title: AccessViolationException from a combo: Attempted to read or write protected memory
body: <p>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:</p>
  
  <p>: 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&amp; m)
     at System.Windows.Forms.Control.DefWndProc(Message&amp; m)
     at System.Windows.Forms.Control.WndProc(Message&amp; m)
     at System.Windows.Forms.ComboBox.WndProc(Message&amp; m)
     at ControlEx.AutoCompleteCombo.WndProc(Message&amp; m)
     at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)
     at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)
     at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)</p>
  
  <p>The code for ControlEx.AutoCompleteCombo.WndProc is as follows:</p>
  
  <pre><code>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 " &amp; Me.Name, ex)
      End Try
  End Sub
  </code></pre>
  
  <p>The error handling was added so we can determine which combo causes the problem when we get an OutOfMemoryException.</p>
  
  <p>Any clues as to what causes this would be muchly appreciated! :-)</p>