Hi,
We are currently using an UltraTree in an application. We have a customer (that I believe is always using a remote desktop connection) that randomly experiences a "Parameter not valid" error.
Here is the stack trace:
System.ArgumentException: Parameter is not valid. at System.Drawing.Image.get_Width() at System.Drawing.Image.get_Size() at Infragistics.Win.EditorWithTextUIElement.GetImageSize(Image img, Size& imageSize) at Infragistics.Win.EditorWithTextUIElement.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.VerifyChildElements(Boolean recursive) at Infragistics.Win.UIElement.VerifyChildElements() at Infragistics.Win.UltraWinTree.UltraTree.SetActiveNode(UltraTreeNode node, Boolean bringIntoView, Boolean adjustHorizontalPosition, NodeActivationReason reason) at Infragistics.Win.UltraWinTree.UltraTree.Infragistics.Win.ISelectionManager.ActivateItem(ISelectableItem item) at Infragistics.Win.SelectionStrategySingle.OnMouseDown(ISelectableItem item, MouseMessageInfo& msginfo, Boolean forceDrag) at Infragistics.Win.SelectionStrategySingle.OnMouseDown(ISelectableItem item, MouseMessageInfo& msginfo) at Infragistics.Win.SelectionStrategySingle.OnMouseMessage(ISelectableItem item, MouseMessageInfo& msginfo) at Infragistics.Win.ControlUIElementBase.ProcessMouseDownHelper(Object sender, MouseEventArgs e) at Infragistics.Win.ControlUIElementBase.ProcessMouseDown(Object sender, MouseEventArgs e) at Infragistics.Win.Utilities.ProcessEvent(Control control, ProcessEvent eventToProcess, EventArgs e) at Infragistics.Win.UltraWinTree.UltraTree.OnMouseDown(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks) 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)
To be honest, I haven't gotten a good read on what is actually causing the error, was hoping that something would jump out given the stack trace.
I believe the following is the version of Infragistics being referenced.
11.2.20112.2050
Thanks in advance!
Steve
I'm glad you hijacked the thread. This was the case for us as well. Used an image from a resource file.
Static image wrapper worked perfectly!
After doing some more digging I was able to narrow my problem down a bit more last night. It seems that it's not necessarily an issue with the Infragistics control in my case (but the control is also not catching the exception that bubbles up).
In my project I have a class that binds to the grid rows. This class contains Image properties that get read during grid row initialization and used as the image icons for button cells. The images in this class are loaded by the resource manager from PNG images embedded in the project's .resx file. In my case, something is either corrupting these images in memory or causing them to be disposed.
I was able to implement a workaround to this by creating a static class that holds cloned instances of these images. Here is some code that illustrates it:
ImageLibrary (static class holding clones of images from the resource file):
public static class ImageLibrary { static ImageLibrary() { Image1 = (Bitmap)Resources.Image1.Clone(); Image2 = (Bitmap)Resources.Image2.Clone();
}
public static Image Image1 { get; private set; }
public static Image Image2 { get; private set; } }
TreeItem class (binds to grid rows)
public class TreeItem {
public TreeItem() {}
public Image Image1 {
get { return ImageLibrary.Image1; }
public Image Image2 {
get {return ImageLibrary.Image2; }
I don't yet know what is causing the images from the resource file to go away. I'm working on that one right now. Hopefully this helps you with your problem as well. If it doesn't, I'm sorry to have hijacked your thread!
Thanks for the info Shawn. I think I ran into something similar a while back (if I recall, using the UltraTree, if the nodes were off the screen and the scrollbar was visible, doing something with them programmatically caused a null ref exception, but that's assuming my memory is correct).
As far as my issue goes, I haven't been able to line up a time to upgrade and roll it out to our customer, so I have no new update.
I just upgraded to 16.2 in my project, but unfortunately it didn't resolve the issue for me. The UltraGrid still crashes.
Something else that might be of benefit is that in my case the crash does not happen until the content of the grid is enough to force the grid to scroll, either vertically or horizontally. It's fine as long as the grid container can full encompass the content. Once the content expands beyond the horizontal or vertical bounds of the control size and the horizontal or vertical scrollbars appear the grid crashes.
And additionally, somewhat related to Steve's problem, I'm using the UltraGrid as a tree. Expanding the bands works great, until I expand enough to make the grid scroll.
In my case I don't think that providing a code sample will be of any benefit since it seems to be related to the user profile...
-Shawn Quillman
If it helps, I'm having a very similar issue with an UltraWinGrid. The control crashes, Red X, etc... The stack trace is very similar as well:
System.ArgumentException: Parameter is not valid. at System.Drawing.Image.get_Width() at System.Drawing.Image.get_Size() at Infragistics.Win.EmbeddableImageRendererUIElement.PositionChildElements() at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) 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.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) 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)
I am using the UltraGrid on a UserControl which is hosted inside an Excel CommonTaskPane (the project is an Excel 2013 VSTO project).
I have been struggling with this for months and months now because it's only happening on a very small number of user machines. It wasn't until today that I have been able to get a hold of one of the machines to debug (they're mostly people around the world and debugging remotely is not an option...)
The "awesome" thing for my issue is that it only happens within the user's profile. If I log in on the machine using my own Windows profile and run the add-in everything works fine. I've done a detect and repair on Office, I've repaired .NET (4.6.1), I've removed all other Excel add-ins, etc.
You've given me hope! I'm currently using the UltraGrid 16.1, but am now going to update to 16.2 to see if your suspicions about the problem being resolved in that version pan out!