WinForms exception not including any code of me

  • Thread starter Thread starter Martin Carpella
  • Start date Start date
M

Martin Carpella

Hi,

I've got the following stacktrace, suddenly while my application was
idle and didn't even have the focus:

System.InvalidOperationException: Object is currently in use elsewhere.
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData)
at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)
at System.Windows.Forms.ControlPaint.DrawImageDisabled(Graphics graphics, Image image, Rectangle imageBounds, Color background, Boolean unscaledImage)
at System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.DrawImageCore(Graphics graphics, Image image, Rectangle imageBounds, Point imageStart, LayoutData layout)
at System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.DrawImage(Graphics graphics, LayoutData layout)
at System.Windows.Forms.ButtonInternal.ButtonFlatAdapter.PaintUp(PaintEventArgs e, CheckState state)
at System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.Paint(PaintEventArgs pevent)
at System.Windows.Forms.ButtonBase.OnPaint(PaintEventArgs pevent)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


The problem is, there is not a single line of my own code within, the
error is purely in the Control implementation. I don't necessarily mean
that there is a bug in the code of the framework, but I cannot find out
where the error could be on my part.

Has anyone got any ideas how I could find out, which of my controls
caused the exception and/or how to deal with the situation.

Best regards,
Martin
 
chanmm said:
Comment out all the parts that dealing with System.Drawing and see.

chanmm

Hmm, this is going to be a problem, as there are quite some user-drawn
components in this project. Just wanted to know if I could get more out
of the stacktrace than there obviously is, or if I could somehow get the
exception to contain an identifier of any control involved.

The main problem is that I do not find a way to reproduce the exception,
it simply happens sometimes (rather rarely).

Best regards,
Martin
 
Back
Top