One of my users is getting a NullReferenceException from an UltraFormManager VerifyControlBoxImage method. This is in a WinForms app using NetAdvantage 2012 Vol 2 (yes, we're stuck using these old controls). It happens when he has a series of windows open and he closes one of them. Of course for the life of me I can't duplicate the issue. Any ideas what might be going on? The exception details are below.
Thanks in advance!Steve
<System.NullReferenceException><message>Object reference not set to an instance of an object.</message><source>Infragistics4.Win.vl2.2</source><targetsite>VerifyControlBoxImage</targetsite><stacktrace><frame>Infragistics.Win.UltraWinForm.UltraFormManager.VerifyControlBoxImage()</frame><frame>Infragistics.Win.UltraWinForm.UltraFormManager.ResolveControlBoxAppearance(AppearanceData& appearanceData, AppearancePropFlags& requestedProps)</frame><frame>Infragistics.Win.UltraWinForm.ControlBoxUIElement.InitAppearance(AppearanceData& appearanceData, AppearancePropFlags& requestedProps)</frame><frame>Infragistics.Win.UIElement.InitializeDrawAppearance(AppearanceData& defaultAppearance, AppearanceData& appearance)</frame><frame>Infragistics.Win.UIElement.DrawElement(UIElementDrawParams&defaultDrawParams)</frame><frame>Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams&drawParams)</frame><frame>Infragistics.Win.UIElement.DrawElement(UIElementDrawParams&defaultDrawParams)</frame><frame>Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams&drawParams)</frame><frame>Infragistics.Win.UIElement.DrawElement(UIElementDrawParams&defaultDrawParams)</frame><frame>Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams&drawParams)</frame><frame>Infragistics.Win.UIElement.DrawElement(UIElementDrawParams&defaultDrawParams)</frame><frame>Infragistics.Win.UIElement.DrawHelper(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean clipText, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics)</frame><frame>Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementsize, Boolean preventAlphaBlendGraphics)</frame><frame>Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode)</frame><frame>Infragistics.Win.UltraControlBase.OnPaint(PaintEventArgs pe)</frame><frame>System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Intl6 layer)</frame><frame>System.Windows.Forms.Control.WmPaint(Message& m)</frame><frame>System.Windows.Forms.Control.WndProc(Message& m)</frame><frame>System.Windows.Forms.NativeWindow.Callback(IntPtr hwnd, Int32 msg, IntPtr wparam, IntPtr lparam)</frame></stacktrace></System.NullReferenceException>
Hi Steve,
I can't be sure without a sample, but it appears from the call stack that the form manager is attempting to draw something related to the form that was just closed. This is not expected because the form manager should know that the form is closed and therefore not attempt to do this.
Is any threading used in your application? Does the issue occur if you close a specific window or is it any window? Is there anything special about the window or windows that cause the exception when closed?
Unfortunately the code resides on a classified network, so getting a sample is impossible. Nothing special with the forms that I can tell. It only seems to be happening when there are four or five specific forms open and one in particular is closed. However, it doesn't happen for all users, just occasionally. Any ideas what I can look for? I'm baffled, especially since the call stack doesn't list any of my code - just WinForms and IG calls.
Hello,
I can provide a bit more info that may give you some direction to begin investigating.
1) The thing that is null is almost certainly a form. We looked into the code for the VerifyControlBox method and a null form is the only thing that could have caused a NullReferenceException.
2) The reason the exception is thrown is because UltraFormManager is attempting to get an icon from the closed form. This happens because the form tries to paint, which leads to the final clue,
3) Somehow, a paint message is being processed for the closed form. If you can figure out why this message is sent even though the form is closed, it would be a major step towards solving this issue. Unfortunately, we can't really even guess at why that paint message might be sent without a reproduction sample.
I'd also like to mention that we are able to sign a non-disclosure agreement if doing so would allow you to send us your code. Please let me know if you would like to pursue this avenue and I will contact you privately through a support case.