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
160
System.ArgumentException: Destination array was not long enough
posted

Hello,

We've encountered a rather strange bug. We have several UltraButtons on a WinForms view.

Application crashes with the following exceptions:

---

System.ArgumentException: Destination array was not long enough.
Check destIndex and length, and the array's lower bounds.
at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
at Infragistics.Win.AppStyling.StyleInfo.Add(RoleState state, StateInfo stateInfo)
at Infragistics.Win.AppStyling.StyleInfo.LoadContents(StyleInfo style, XmlReader reader, StyleParseInfo parseInfo)
at Infragistics.Win.AppStyling.StyleInfo.LoadContents(StyleInfo style, StyleParseInfo parseInfo)
at Infragistics.Win.AppStyling.StyleInfo.Parse()
at Infragistics.Win.AppStyling.StyleInfo.get_StateFlags()
at Infragistics.Win.AppStyling.StyleManager.CreateStyleInfo(UIRole role)
at Infragistics.Win.AppStyling.UIRole.VerifyCache()
at Infragistics.Win.AppStyling.UIRole.ResolveAppearance(AppearanceData& appearance, AppearancePropFlags& requestedProps, RoleState state)
at Infragistics.Win.Misc.UltraButtonBase.ResolveAppearanceHelper(UIElementButtonState buttonState, AppearanceData& appearance, AppearancePropFlags& requestedProps, UIRole buttonRole)
at Infragistics.Win.Misc.UltraButtonBase.ResolveAppearance(UIElementButtonState buttonState, AppearanceData& appearance, AppearancePropFlags& requestedProps)
at Infragistics.Win.Misc.UltraButtonUIElement.InitAppearance(AppearanceData& appearance, AppearancePropFlags& requestedProps)
at Infragistics.Win.Misc.UltraButtonUIElement.PositionChildElements()
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.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.UltraControlBase.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)

---

System.ArgumentException: Parameter is not valid.
at System.Drawing.Image.get_Width()
at System.Drawing.Image.get_Size()
at Infragistics.Win.DrawUtility.DrawImageBackground(Graphics g, AppearanceData& appearanceData, AlphaBlendMode alphaMode, Rectangle invalidRect, Control control, Rectangle relativeRect, ImageAttributes imgAttributes, ColorRenderMode colorRenderMode, Boolean isEnabled)
at Infragistics.Win.UIElementDrawParams.DrawImageBackground(AppearanceData& appearance, Rectangle rect, Rectangle invalidRect, Boolean enabled)
at Infragistics.Win.Misc.UltraPanelClientAreaUIElement.DrawImageBackground(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)
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.Misc.UltraPanelClientArea.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintTransparentBackground(PaintEventArgs e, Rectangle rectangle, Region transparentRegion)
at System.Windows.Forms.Control.PaintBackground(PaintEventArgs e, Rectangle rectangle, Color backColor, Point scrollOffset)
at System.Windows.Forms.Control.PaintBackground(PaintEventArgs e, Rectangle rectangle)
at System.Windows.Forms.Control.OnPaintBackground(PaintEventArgs pevent)
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)

---

Any idea why?

Thanks in advance.

Parents
No Data
Reply
  • 48586
    posted

    Hello ,

     

    Based on the call stack of the exception  it seems that you are using your UserControl in a multithreading application (Windows Forms controls are not thread safety). It seems to me that you  have applied isl from a speared thread (I assume that StyleManager is not in the same thread as the component, or you are doing something with the StyleManager from a separate thread), so when the button is redrawn it cannot copy appearance array the isl. Without sample which demonstrates this issue, those are the only assumptions that I have about what exactly happens here. BeginUpdate()/EndUpdate() might helped here, but it will be better if you  put all the code that interact with the component in the main UIThread.

     

    Please let me know if you have any further questions.

     

     

Children