We recently added the dock manager to a major traffic area of our winforms application.We are running on infragistics 20.2.20202.14Here is one example of the stacktrace:
at Infragistics.Win.UltraWinDock.DockableWindowPlaceholderUIElement.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.UltraWinDock.WindowDockingAreaUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UIElement.DrawHelper(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean clipText, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics, Nullable`1 zoomFactor) 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) at Infragistics.Win.ManagedContainerControlBase.OnPaint(PaintEventArgs pe) at Infragistics.Win.UltraWinDock.WindowDockingArea.OnPaint(PaintEventArgs pe) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer) at System.Windows.Forms.Control.WmPaint(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ContainerControl.WndProc(Message& m) at System.Windows.Forms.Control.ControlN ativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlN ativeWindow.WndProc(Message& m) at System.Windows.Forms.N ativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Is there any direction on what this crash is and how we can handle it or prevent it?
Hello and thank you for contacting Infragistics. To properly diagnose the behavior please provide a sample isolating the behavior. When does this issue happen and does it occur every time?
The above stack trace is coming directly from our customers.And there are more crashes I'm seeing from the DockManager as well, but it looks like coming here for help will not be a useful practice.If I could reproduce myself, I could show it to you. But I can't and I don't have access to the code, just the stack traces that clearly point to infragistics as doing something that is invalid... it would be nice if infragistics was handling these cases instead of just throwing an exception and crashing our whole application.Here are more stacktraces...Operation is not valid due to the current state of the object.
at Infragistics.Win.ChildControlEventManager..ctor(Control rootControl) at Infragistics.Win.ControlUIElementBase.MouseEventManager..ctor(ControlUIElementBase controlElement) at Infragistics.Win.ControlUIElementBase.Initialize(Control control, IUltraControl ultraControl, ProcessEvent eventsToProcess) at Infragistics.Win.ControlUIElementBase..ctor(Control control, IUltraControl ultraControl, Boolean hookEvents) at Infragistics.Win.UltraWinDock.DockableWindowUIElement..ctor(DockableWindow control, UltraDockManager dockManager) at Infragistics.Win.UltraWinDock.DockableWindow.get_ControlUIElement() at Infragistics.Win.ManagedContainerControlBase.Infragistics.Win.IUltraControlElement.get_MainUIElement() at Infragistics.Win.DrawUtility.GetGdiDrawStringFlags(Control ctrl) at Infragistics.Win.ImageAndTextUIElement.MeasureStringCallback.CreateDelegate(Control ctrl, Size layoutArea) at Infragistics.Win.ImageAndTextUIElement.CalculateTextSize(String text, HotkeyPrefix hotkey, Boolean vertical, Control control, AppearanceData& appearance, MeasureStringDelegate measureString, Boolean wrapText, GdiDrawStringFlags drawStringFlags, Size layoutArea) at Infragistics.Win.ImageAndTextUIElement.CalculateTextSize(String text, HotkeyPrefix hotkey, Boolean vertical, Control control, AppearanceData& appearance, Size layoutArea) at Infragistics.Win.ImageAndTextUIElement.CalculateTextSize(String text, HotkeyPrefix hotkey, Boolean vertical, Control control, AppearanceData& appearance) at Infragistics.Win.UltraWinDock.DockablePaneBase.PaneMetrics.UpdateSlidingGroupSizeInfo() at Infragistics.Win.UltraWinDock.DockablePaneBase.PaneMetrics.UpdateSizeInformation() at Infragistics.Win.UltraWinDock.DockablePaneBase.get_ContentsMargins() at Infragistics.Win.UltraWinDock.DockablePaneBase.InternalProcessPaneSize(Boolean enforceMinMax, Size newSize, Size displaySize) at Infragistics.Win.UltraWinDock.DockableGroupPane.AdjustSplitGroupPaneSize(Size availableSize) at Infragistics.Win.UltraWinDock.DockableGroupPane.AdjustChildPaneSize() at Infragistics.Win.UltraWinDock.DockablePaneBase.InternalProcessPaneSize(Boolean enforceMinMax, Size newSize, Size displaySize) at Infragistics.Win.UltraWinDock.DockableGroupPane.InternalProcessPaneSize(Boolean enforceMinMax, Size newSize, Size displaySize) at Infragistics.Win.UltraWinDock.DockAreaPane.InternalProcessPaneSize(Boolean enforceMinMax, Size newSize, Size displaySize) at Infragistics.Win.UltraWinDock.DockablePaneBase.SyncPaneSize() at Infragistics.Win.UltraWinDock.DockableControlPane.Pin() at Infragistics.Win.UltraWinDock.UltraDockManager.ControlPaneRemoved(DockableControlPane pane) at Infragistics.Win.UltraWinDock.DockableControlPanesCollection.Remove(DockableControlPane pane) at Infragistics.Win.UltraWinDock.DockableControlPane.OnControlDisposed(Object sender, EventArgs e) at System.EventHandler.Invoke(Object sender, EventArgs e) at System.ComponentModel.Component.Dispose(Boolean disposing) at System.Windows.Forms.Control.Dispose(Boolean disposing) at System.ComponentModel.Component.Dispose() at System.Windows.Forms.Control.Dispose(Boolean disposing) at Infragistics.Win.ManagedContainerControlBase.Dispose(Boolean disposing) at System.ComponentModel.Component.Dispose() at System.Windows.Forms.Control.Dispose(Boolean disposing) at Infragistics.Win.ManagedContainerControlBase.Dispose(Boolean disposing) at Infragistics.Win.UltraWinDock.AutoHideControl.Dispose(Boolean disposing) at System.ComponentModel.Component.Dispose() at System.Windows.Forms.Control.Dispose(Boolean disposing) at System.Windows.Forms.Form.Dispose(Boolean disposing) at TransPlus.FleetManager.Features.Forms.TransPlusForm.Dispose(Boolean disposing) at TransPlus.FleetManager.frmTripBoard.Dispose(Boolean Disposing) at System.ComponentModel.Component.Dispose() at System.Windows.Forms.Control.Dispose(Boolean disposing) at System.ComponentModel.Component.Dispose() at System.Windows.Forms.Control.Dispose(Boolean disposing) at System.Windows.Forms.Form.Dispose(Boolean disposing) at TransPlus.FleetManager.Features.Forms.TransPlusForm.Dispose(Boolean disposing) at frmMDI.Dispose(Boolean Disposing) at System.Windows.Forms.Form.WmClose(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at TransPlus.FleetManager.Features.Forms.TransPlusForm.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Drawing.Graphics.CheckErrorStatus(Int32 status) at System.Drawing.Graphics.FillRectangle(Brush brush, Int32 x, Int32 y, Int32 width, Int32 height) at System.Drawing.Graphics.FillRectangle(Brush brush, Rectangle rect) at Infragistics.Win.DrawUtility.DrawBackColor(Control control, Graphics graphics, AppearanceData& appearanceData, Rectangle rect, Rectangle invalidRect, Boolean enabled, IDrawCache drawCache, AlphaBlendMode alphaBlendMode, Blend blend, Boolean mirrorBackground) at Infragistics.Win.UIElementDrawParams.DrawBackColor(Rectangle rect) at Infragistics.Win.UltraWinGrid.CellUIElement.DrawBackColor(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawHelper(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean clipText, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics, Nullable`1 zoomFactor) 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) at Infragistics.Win.UltraWinGrid.UltraGridUIElement.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode) at Infragistics.Win.UltraControlBase.OnPaint(PaintEventArgs pe) at Infragistics.Win.UltraWinGrid.UltraGrid.OnPaint(PaintEventArgs pe) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer) 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)
So... this methods looks pretty safe to me. It's checking for null on everything it uses, except for 'this.Control'The implementation for this.Control is on UIElement, which is the base class. And that basically returns the control the UIElement belongs to. So if this element is painting and it's Control is null, something has gone seriously wrong. I suppose something like this could happen, in theory, if during the Paint operation, you disposed of the control while it was in the middle of painting. But that seems very unlikely.
protected override void PositionChildElements() { // the dockable window element gets positioned here. if (this.pane != null && this.pane.Container != null && this.Control.Contains(this.pane.Container)) { System.Drawing.Rectangle rect = this.DrawingRectInsideBorders; this.pane.Container.Bounds = rect; if (rect.Width > 0 && rect.Height > 0) this.pane.Container.Visible = true; ControlUIElementBase controlElement = ((IUltraControlElement)pane.Container).MainUIElement; if (controlElement != null && !controlElement.IsDrawing) controlElement.DirtyChildElements(); } base.PositionChildElements(); }
A much more likely explanation, IMO, is that the multiple threads in your application are not properly marshalling data across threads. And so it's getting into a race condition and something is in a bad state. Using threads in WinForms can be very tricky because you are not always in control of the communication across threads unless you are extremely careful about limiting the scope of the background threads.
As for catching this Exception, I don't see any way to do that in this case. If this were a control like UltraGrid, then you could derive your own control from the grid and override OnPaint and then wrap the call to the base in a try...catch. But since this is a Dock Windows, you are not in control of creating or managing that control, and so there's no way for you to create a derived instance and add it in to the DockManager.
Even if you could handle the exception, I expect that it would only mask the problem and your application would just blow up in some other place. That's what will almost-certainly happen if this is a threading issue.
Thanks for the response Mike, that was helpful.Focusing on the first exception that I posted, as this is the exception we are continuing to get regularly, I don't have a lot of information on what the users are doing that causes this exception.We do use threads throughout our application, but not extensively and I can't find specific threading operations that would cause this crash.We are using 'double buffering' on one of the controls that we are embedding inside the dockmanager panel, could this be causing an issue?
protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ExStyle |= 0x02000000; return cp; } }
What I would really like to know though is what is the object that could possible be null in the method:at Infragistics.Win.UltraWinDock.DockableWindowPlaceholderUIElement.PositionChildElements()Is there any way to get visibility on this method and what it is doing?Can I somehow catch this exception and recover from it?
Hi Dave,
With only a call stack (or 2) to go on, the best we can do here is make some educated guesses. These two exceptions are completely different. Do you have any information about what the user(s) were doing when they occurred? In my experience, a GDI+ exception like this one typically happens when you call a GDI+ drawing method and one of the parameters being passed into the method is invalid. This is usually an image or something like that, but since this one is happening on FillRectangle, my best guess is that either the Brush being passed in here is disposed. My second guess would be that the machine is simply out of memory and can't perform the operation.
The other exception is completely new to me. Never seen one like that before. But the exception appears to be happening inside the constructor of an object. And since the call stack shows the constructor itself blowing up, and not some line of code inside that constructor, it once again hints at a problem with not enough system memory. Of course, if that were the case, you would probably be getting an OutOfMemoryException. Not sure what the "current state of the object means" or what object it's referring to. Unless maybe these two Exceptions are related and the constructor is forcing a paint and so the second Exception is the InnerException to the first one. My only other guess here is that your application is using multiple threads and somehow getting into a bad state. Are you using threads?