C# Win Forms Access Violation Exception
Posted
by Goober
on Stack Overflow
See other posts from Stack Overflow
or by Goober
Published on 2010-03-25T09:56:36Z
Indexed on
2010/03/25
10:13 UTC
Read the original article
Hit count: 497
I keep getting the following error:
System.AccessViolationException was unhandled Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt." Source="FEDivaNET" StackTrace: at Diva.Handles.FEDivaObject.dropReference() at Diva.Handles.FEDivaObject.!FEDivaObject() at Diva.Handles.FEDivaObject.Dispose(Boolean ) at Diva.Handles.FEDivaObject.Finalize() InnerException:
Any ideas what the issue could be? - I'm using a library that is written in C++ and isn't designed for multithreading, yet I'm hammering it about 3000 times with requests every 6 minutes.
CODE
delegate void SetTextCallback(string mxID, string text);
public void UpdateLog(string mxID, string text)
{
//lock (thisLock)
//{
if (listBoxProcessLog.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(UpdateLog);
this.BeginInvoke(d, new object[] { mxID, text });
}
else
{
//Get a reference to the datatable assigned as the datasource.
//DataTable logDT = (DataTable)listBoxProcessLog.DataSource;
//logDT.Rows.Add(DateTime.Now + " - " + mxID + ": " + text);
if (text.Contains("COMPLETE") || (text.Contains("FAILED")))
{
if (progressBar1.Value <= progressBar1.MaxValue)
{ progressBar1.Value += 1; }
}
}
//}
}
Baring in mind that even when the Lock and the DataTable weren't commented out, the error still occurred!
© Stack Overflow or respective owner