I am working on an application in which the client experiences a problem every couple of months (they can work around the problem by restarting the application). The stack trace always points to the first line of the overridden (class inherits from Control ) OnPaint() method, which calls the e.Graphics.Clear() call.
I read about Microsoft documentation that:
The Clear method clears the state of the graphic object and should not be called when the graphic object cannot be updated. For example, if the Clear method is called on a secure desktop in a terminal server session, an external exception may occur, leaving the Graphics object in an inconsistent state.
I verified that application users do not start the application from a remote machine. I also read that:
When overriding OnPaint in a derived class, be sure to call the OnPaint method of the base class so that registered delegates receive the event.
Could the fact that the application does not currently call the base class' OnPaint() cause a "general error in GDI +" ExternalException error message?
Unfortunately, I take a hit in the dark on this issue because I cannot reproduce it, and this happens very rarely in production scenarios. Can someone give an idea?
source share