Re: Tracing an exception

Dean Cleaver <[email protected]> Fri, 14 Mar 2008 09:53:24 +1300
Newsgroups gmane.comp.windows.devel.dotnet.clr
Message-ID <4543A775711185429E59B18055D4167423227D@sxslakl004.xceptionsoftware.com>
But I figured if it was my code using it, my code would have been
included in the stack trace?

-----Original Message-----
From: Discussion of development on the .NET platform using any managed
language [mailto:[email protected]] On Behalf Of Peter
Ritchie
Sent: Friday, 14 March 2008 9:38 a.m.
To: [email protected]
Subject: Re: [DOTNET-CLR] Tracing an exception

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(PictureBoxSi
z
>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?

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
This list is hosted by DevelopMentor(r)  http://www.develop.com

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

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
This list is hosted by DevelopMentor=AE  http://www.develop.com

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