Hello,
I am using the latest 2020.1 components in a winforms application on a windows 10 machine.
When I close a form, some callback is triggered which as far as I can tell is/was not set up by my code that causes the 'parameter is not valid' exception. What is strange is this is not consistently reproducible. Opening the app fresh and performing the exact same steps multiple times results in this exception maybe 1/4 times.
I cannot provide the source because the solution is proprietary and far to large to share, however from the stack trace, none of my code is involved so I'm not sure that my code would help in any way:
at System.Drawing.Image.get_Width() at System.Drawing.Image.get_Size() at Infragistics.Win.ImageAndTextUIElement.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(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.UltraControlBase.OnPaint(PaintEventArgs pe) at Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea.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)
When this exception happens, all my tools (file menu and quicklaunch toolbars) are replaced with a giant red 'X'.
If this is a bug in the components, is there a way to work around this?
Unfortunately applying the 2020.1.87 service release did not fix the issue.
So after many hours wrestling with Visual Studio just to get it to break where the exception actually happens here is what I found:
1) The image is not null but 'invalid'. I don't know how that's possible but there it is.
So when I first saw this I thought maybe something in my code was changing an image and got interrupted by some threading that I have no control over.
So since I was using a factory pattern to create tools via code, I decided to rip all that out and use the graphical designer to build all my menues (since that's what all the other forms in the system do and they don't seem to have a problem crashing the toolbar). As far as I can tell, the way all my tools are registered is the same as other forms.
Next, since the exception occurred at:Infragistics.Win.ImageAndTextUIElement.PositionChildElementsat this line: Size scaleSize = provider.GetScaledImageSize(this);I decided to see what provider.Control.Name was.
It turns out it is the Top Dock Panel. Other than registering a new toolbar with the toolbarmanager, I don't touch the dockpanel at all in that Form so I have no clue how to debug this further. As far as I can tell, when the form closes, something happens during disposal that corrupts the draw area of the top DockPanel.I will try using the service release, hopefully it is an msi and I can use the update utility, otherwise this will be a long process to manually update all the references.
Frankly, I'm not sure a breakpoint will be all that helpful here. What you will almost certainly find is that the image is disposed, but breaking here will not tell you why.
I thought that the WinGrid issues I mentioned earlier is fixed in the latest service release, but I might be wrong about that. There's another service release coming soon (next week). I strongly suspect that's the issue. Here are the links to download the bi-weekly. I strongly suspect this will fix the problem.
v19.2: http://builds.infragistics.com/products/WinForms/2019.2/Infragistics_WinForms_20192.462_SR.zip
v20.1: http://builds.infragistics.com/products/WinForms/2020.1/Infragistics_WinForms_20201.87_SR.zip
If not, then I think the best path forward would be for you to try to reduce your real application down to something we could run and debug and we could try to see what's going on here.
If you need to put breakpoints in the code of the control, you can find the source code for our components as well as .pdb files(symbols) under My Keys & Downloads section of your account.
Please let me know if you need further information.
Sincerely,Tihomir TonevAssociate Software DeveloperInfragistics
If you have a suggestion on how I can, without access to infragistics code, determine which Toolbar element is attempting to set which specific image while inside a native callback, please send me a link to instructions on how to do this or provide the details here because as far as I am aware, this is not possible.