I want to create autocomplete text which is when user typed number, the user typed text+fixed text appears as autocomplete text. So I create autocompleteStringCollection
in textchanged
event. But it gives me AccessViolationException
:
System.AccessViolationException HResult=0x80004003
Message=An attempt was made to perform a read or write operation on protected memory. Other memory may be broken. Source= Stack trace:
Is there any suggestion?
Here is my code!!!!
private void textbox_TextChanged(object sender,EventsArgs e)
{
AutocompleteStringCollection a=new AutocompleteStringCollection();
if(textbox.Text.Length!=0)
{
a.AddRange(new String[]{textbox.Text+"greater than",
textbox.Text+"greater than equal"});
}
textbox.AutocompleteCustomSource=a;
}
Lacking any actuall code to debug, all I can give you is the gist.
AccessViolationException is part of the OS Memory Protection. AV Exceptions usually requires someone handling naked pointers and bleeping stuff up, wich is scarily easy to do.
You usually do not get them in .NET. The designers went out of their way to prevent you from needing to handle naked pointers. There is still a few possible causes:
User contributions licensed under CC BY-SA 3.0