Trying to secure a memory read or write. This often indicates that other memory is corrupt

I've created a control combobox Winforms AutoComplete, inheriting ComboBox, with the following method:

Protected Overrides Sub OnKeyPress(ByVal e As System.Windows.Forms.KeyPressEventArgs)
        MyBase.OnKeyPress(e)
        Dim text As String = Me.Text
        If Char.IsLetter(e.KeyChar) Then
            text = text + e.KeyChar
        End If
        If (text.Length = AutoCompleteSearchChars And Char.IsLetter(e.KeyChar)) Then
            SetAutoCompleteMethod.Invoke(text)
            Me.AutoCompleteSource = AutoCompleteSource.ListItems
            Me.Text = text
            Me.SelectionStart = text.Length
            Me.SelectionLength = 0
            If Me.Items.Count > 0 Then
                Me.SelectedIndex = 0
            End If
            e.Handled = True
        End If
    End Sub

"SetAutoCompleteMethod" - is a delegate pointing to the method that fills the combobox items based on the use of the current text in the combo box as a prefix to the wildcard search. It provides similar functionality to the drop-down list of autocomplete ajax.

, " . , ". . :

System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG & msg) System.Windows.Forms.Application.ComponentManager.System.Windows.Forms. UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32, Int32 pvLoopData) System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 , ApplicationContext)
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 , ApplicationContext)
System.Windows.Forms.Application.Run(ApplicationContext ) Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String [] commandLine) ApplicationShell.My.MyApplication.Main(String [] Args) 17d14f5c-a337-4978-8281-53493378c1071.vb: 81 System.AppDomain._nExecuteAssembly ( , String [] args) System.AppDomain.ExecuteAssembly(String , assemblySecurity, String [] args) Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() System.Threading.ThreadHelper.ThreadStart_Context ( ) System.Threading.ExecutionContext.Run(ExecutionContext executeContext, ContextCallback , ) System.Threading.ThreadHelper.ThreadStart()

- , ?

+3
2

, , , , -. VB , .Net, , - . , , , , , .

+4

, ToString() , . , .

, NullReferenceException.

, # .NET? .

0

All Articles