System.AccessViolationException
HResult=0x80004003
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=<Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace>
Error with the ntdll.dll
I am building a software to communicate with a led controller card, the software uses UDP communication with a async process that's always waiting for a new message, when this message arrives it’s handled with a delegate method and its shown on a rich text box, this is the only “out of ordinary” part of the code, I will print this below, but the error does not occur there, when I enable or disable a panel, but that’s very weird, I will paste a part of the code because I can’t post the full code here.
private void StartListening()
{
if (!form_closed)
Client.BeginReceive(Receive, new object());
}
private void Receive(IAsyncResult ar)
{
try
{
ip = new IPEndPoint(IPAddress.Any, PORT_NUMBER);
byte[] bytes = Client.EndReceive(ar, ref ip);
rec_msg = Encoding.ASCII.GetString(bytes);
if (rec_msg != "broadcast_teste")
{
ShowMessage(richTextBox1, rec_msg);
}
}
catch (Exception ex)
{
ShowMessage(richTextBox1, ex.Message);
}
StartListening();
}
delegate void ShowMessageDelegate(RichTextBox richtextbox1, string message);
private void ShowMessage(RichTextBox richtextbox, string message)
{
if (richtextbox.InvokeRequired)
{
ShowMessageDelegate showMessageDelegate = ShowMessage;
richtextbox.Invoke(showMessageDelegate, new object[] { richtextbox, message });
}
else
{
// some simple logic to write data on text boxes //
richtextbox.Text += message + "\r\n";
richtextbox.SelectionStart = richtextbox.TextLength;
richtextbox.ScrollToCaret();
}
}