Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
195
"Object is currently in use elsewhere" exception OnPaint
posted

I am currently using an UltraWinToolbar.  We are - very infrequently - seeing the Exception below come up from the OnPaint of the toolbar.  What I suspect is happening is that I am using a single Appearance object as the appearance for two different tools, and there sometimes is a race condition as the two try to access the same image at the same time.  I plan to switch to using two different appearances which reference the same image, but since this is not at all an easily reproducible issue, it's also not a fix which I can verify with much confidence. 

So I thought I'd ask the experts - have you seen an issue like this before?  Should I avoid using the same appearance object for more than one tool?  Does this fix seem plausible to avoid this rare, timing-sensitive exception?

It's also possible the race condition is for the bitmap object wrapper, or even further down in the ResourceManager.

appearanceEmail = new Infragistics.Win.Appearance();

appearanceEmail.Image = global::FrontendControls.Resources.FrontendControlsResources.email;

appearanceEmail.ForeColor = System.Drawing.SystemColors.ControlText;

--------------------------

System.InvalidOperationException: Object is currently in use elsewhere.
   at System.Drawing.Image.get_Width()
   at System.Drawing.Image.get_Size()
   at Infragistics.Win.UltraWinToolbars.PopupToolDropDownButtonUIElement.PositionChildElements()
   at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
   at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
   at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
   at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
   at Infragistics.Win.UIElement.DrawHelper(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean clipText, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics)
   at Infragistics.Win.UIElement.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics)
   at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize, Boolean preventAlphaBlendGraphics)
   at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize)
   at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode)
   at Infragistics.Win.UltraControlBase.OnPaint(PaintEventArgs pe)
   at Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea.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)

Parents
No Data
Reply
  • 44743
    posted

    Are you using the image on forms which are on different threads? If so, it is definitely possible that is what's causing the error and I would recommend cloning the image to use on different threads. If not, I'm not sure what would cause the issue, but I don't think it would be caused by using the same appearance on two tools, so I'm not sure if fixing that would help. If your application is not multi-threaded I would submit the issue to the support group: http://ko.infragistics.com/gethelp.

Children