views:

351

answers:

4

Hi,

I have a piece of software that has worked fine on many machines, althoughon one machine there is a problem that appears to occur occasionaly, the MenuStrip and the ToolStrip both appear as a blank white background with a red cross over it, as a custom control would if you created a null object. This doesn't happen whilst I am debugging and I don't know how to make the problem re-occur, but it does happen. I was wondering if anyone knew what could be the problem?

Would it be the version of the .NET framework?

Thanks

A: 

Sounds like a symptom of an Out Of Memory Exception to me.

Edit: Which can sometimes lead onto a System.InvalidOperationException: BufferedGraphicsContext

Pondidum
A: 

Are you trying to update the GUI controls from a thread other than the GUI thread? Combine the cross thread operation with an exception handler that swallowed everything and we had the behavior you describe (on a grid control, not a menustrip bar) on an app I was maintaining.

Jason Punyon
+1  A: 

This is a common occurrence when there's a GDI+ problem ("The Red X of Death"). Are you doing any custom drawing in OnPaint? Or perhaps there's a graphic resource or a glyph which is corrupt or being improperly disposed of.

Edit: I've re-read your question. You seem to have this only on one of the machines. I've googled around a bit for this, and I stumbled upon this old thread. The post at the bottom suggests that there might be an issue with Virtual Memory turned off:

We did manage to solve this - we were seeing the problem on a device running XP embedded. The XPe image developer had turned off Virtual Memory and as soon as we turned it on the problem went away. I believe it is just a symptom of the system running out of memory to display the graphics (maybe particularly if you use a lot of double buffering)

Hope that helps.

hmemcpy
No, I'm not doing any custom drawing, just using them as standard, I understand what you mean as i've stumbled across that when I have created custom controls in the past. Thanks for your help anyhow!
ThePower
Sorry, I misread your question the 1st time.
hmemcpy
Thanks for the update and the information
ThePower
A: 

Definitively sounds like a cross-thread problem.

Make sure you use Invoke when accessing controls and/or firing events from a thread that is not the main UI thread.

Dun3