Intermittently, our application crashes with :
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at System.Drawing.SafeNativeMethods.Gdip.GdipDrawLineI(HandleRef graphics, HandleRef pen, Int32 x1, Int32 y1, Int32 x2, Int32 y2) at System.Drawing.Graphics.DrawLine(Pen pen, Int32 x1, Int32 y1, Int32 x2, Int32 y2) at Infragistics.Win.DrawUtility.DrawBordersHelper(Graphics gr, Border3DSide sides, Pen leftTopPen, Pen rightBottomPen, Rectangle rect, Rectangle invalidRect, Boolean isDashedPen).......
I have attached the full stack trace.
We have used this product for many years and have never seen anything like this. It happens for multiple users, many different machines. There seems to be no pattern. Our application uses the grid, toolbars, dockmgr, etc, but nothing out of the ordinary. We have no unmanaged code and definitely are not doing anything related to drawing or GDI. Searching on google has some hits, mostly related to Pen/Brush disposal.
I have submitted this issue to support, but of course without a reproduceable example, I don't expect great results.
I was hoping someone here could give me some ideas of what the problem might be. Could our managed code be causing this?
Thanks in advance.
Scott
Sure enough, found a RefreshFilters and a RefreshSort call which wasn't being 'invoked' properly.
The crashing seems to have subsided. It will take a while to be sure, but look good so far (couple days).
I thank you. I would have never thought to look in this direction.
Scott,
It would certainly be handy if an exception were thrown when not properly updating the UI thread, as this would fix a lot of headaches and tracking down threading issues. The problem comes when you have a flow of events such as updating data on a background thread and pushing it into a data source, which then tells the grid that data has been updated, so the grid tries to paint itself; this essentially amounts to performing a UI action while on a non-UI thread.
-Matt
Yes, for sure there is a thread which updates the grid.
I do believe we are invoking everything properly on the gui thread (via invoke). I thought you always get the cross-threaded operation not valid exception (or something like that) if you are not properly invoking on the gui thread.
Either way, it's worth a try, I will definitely try 'unthreading' the application and see if it helps.
Thanks,
Given by how it's intermittent, it sounds like it might be caused by a threading issue. Are you updating any data or doing anything that could cause the UI to be updated from another thread? If so, you will need to make sure that all code that touches the UI is marshalled back to the main thread.