Re: Tracing an exception

Peter Ritchie <[email protected]> Thu, 13 Mar 2008 16:37:59 -0400
Newsgroups gmane.comp.windows.devel.dotnet.clr
Message-ID <LISTSERV%[email protected]>
Ahh, the nebulous Object is currently in use elsewhere error.

This occurs directly out of GDI+.  It occurs because GDI+ thinks you've
asked it to do two things at once with a single GDI object.  This mostly
occurs when you try and do something with a GDI object on a background
thread (i.e. getting the size of an image on the main thread and modifying
an image on another thread constitutes doing two things at the same time
with GDI+.

Getting much more detail out of the exception won't help you much until
you find where the "other use" is.

On Fri, 14 Mar 2008 09:23:54 +1300, Dean Cleaver
<[email protected]> wrote:

>I've had this exception logged in my system:
>
>System.InvalidOperationException: Object is currently in use elsewhere.
>   at System.Drawing.Image.get_Width()
>   at System.Drawing.Image.get_Size()
>   at
>System.Windows.Forms.PictureBox.ImageRectangleFromSizeMode(PictureBoxSiz
>eMode mode)
>   at System.Windows.Forms.PictureBox.get_ImageRectangle()
>   at System.Windows.Forms.PictureBox.OnPaint(PaintEventArgs pe)
>   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.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)
>
>As you can see, none of it is my code - so any ideas on how I go about
>tracing what's causing it?

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com