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
585
System.NullReferenceException in OnPaint
posted

I just got these stacktraces when refreshing a grid:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Infragistics.Win.UltraWinGrid.UltraGridBand.get_CellPaddingResolved()
   at Infragistics.Win.UltraWinGrid.UltraGridColumn.get_CellSizeDefault()
   at Infragistics.Win.UltraWinGrid.UltraGridColumn.get_Width()
   at Infragistics.Win.UltraWinGrid.ColumnHeader.get_Extent()
   at Infragistics.Win.UltraWinGrid.ViewStyleBase.GetHeaderExtent_AutoFitExtendLastColumn_NonRowLayout(HeaderBase header)
   at Infragistics.Win.UltraWinGrid.ViewStyleBase.AddBandHeaders(ColScrollRegion csr, UltraGridBand band)
   at Infragistics.Win.UltraWinGrid.ViewStyleSingle.RecreateHeaderList(ColScrollRegion csr)
   at Infragistics.Win.UltraWinGrid.ColScrollRegion.RegenerateVisibleHeaders()
   at Infragistics.Win.UltraWinGrid.DataAreaUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
   at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
   at Infragistics.Win.UltraWinGrid.UltraGridUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
   at Infragistics.Win.UIElement.VerifyChildElements(Boolean recursive)
   at Infragistics.Win.ControlUIElementBase.VerifyIfElementsChanged(Boolean verify, Boolean syncMouseEntered)
   at Infragistics.Win.ControlUIElementBase.ProcessMouseMoveHelper(Object sender, MouseEventArgs e)
   at Infragistics.Win.ControlUIElementBase.ProcessMouseMove(Object sender, MouseEventArgs e)
   at Infragistics.Win.Utilities.ProcessEvent(Control control, ProcessEvent eventToProcess, EventArgs e)
   at Infragistics.Win.UltraControlBase.OnMouseMove(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseMove(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
System.NullReferenceException: Object reference not set to an instance of an object.
   at Infragistics.Win.UltraWinGrid.UltraGridBand.get_CellPaddingResolved()
   at Infragistics.Win.UltraWinGrid.UltraGridBand.GetMinRowHeightHelper(Boolean synchronized)
   at Infragistics.Win.UltraWinGrid.UltraGridBand.get_RowHeightResolved()
   at Infragistics.Win.UltraWinGrid.RowScrollRegion.ResetScrollInfo()
   at Infragistics.Win.UltraWinGrid.RowScrollRegion.RegenerateVisibleRows(Boolean resetScrollInfo)
   at Infragistics.Win.UltraWinGrid.RowScrollRegion.WillScrollbarBeShown(ScrollbarVisibility assumeColScrollbarsVisible)
   at Infragistics.Win.UltraWinGrid.RowScrollRegion.PositionScrollbar(Boolean resetScrollInfo)
   at Infragistics.Win.UltraWinGrid.RowScrollRegion.SetOriginAndExtent(Int32 origin, Int32 extent)
   at Infragistics.Win.UltraWinGrid.DataAreaUIElement.ResizeRowScrollRegions()
   at Infragistics.Win.UltraWinGrid.DataAreaUIElement.PositionChildElements()
   at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
   at Infragistics.Win.UltraWinGrid.UltraGridUIElement.PositionChildElements()
   at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
   at Infragistics.Win.UltraWinGrid.UltraGridUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
   at Infragistics.Win.UIElement.VerifyChildElements(Boolean recursive)
   at Infragistics.Win.ControlUIElementBase.VerifyIfElementsChanged(Boolean verify, Boolean syncMouseEntered)
   at Infragistics.Win.ControlUIElementBase.get_CurrentCursor()
   at Infragistics.Win.UltraControlBase.get_Cursor()
   at System.Windows.Forms.Control.WmSetCursor(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
System.NullReferenceException: Object reference not set to an instance of an object.
   at Infragistics.Win.UltraWinGrid.UltraGridBand.get_CellPaddingResolved()
   at Infragistics.Win.UltraWinGrid.UltraGridColumn.get_CellSizeDefault()
   at Infragistics.Win.UltraWinGrid.UltraGridColumn.get_Width()
   at Infragistics.Win.UltraWinGrid.ColumnHeader.get_Extent()
   at Infragistics.Win.UltraWinGrid.UltraGridBand.CalculateBandMetrics(UltraGridBand priorBand)
   at Infragistics.Win.UltraWinGrid.BandsCollection.CalculateBandMetrics(Int32 pass)
   at Infragistics.Win.UltraWinGrid.ColScrollRegionsCollection.InitializeMetricsHelper()
   at Infragistics.Win.UltraWinGrid.ColScrollRegionsCollection.InitializeMetrics()
   at Infragistics.Win.UltraWinGrid.RowScrollRegion.RegenerateVisibleRows(Boolean resetScrollInfo)
   at Infragistics.Win.UltraWinGrid.RowScrollRegion.WillScrollbarBeShown(ScrollbarVisibility assumeColScrollbarsVisible)
   at Infragistics.Win.UltraWinGrid.RowScrollRegion.PositionScrollbar(Boolean resetScrollInfo)
   at Infragistics.Win.UltraWinGrid.RowScrollRegion.SetOriginAndExtent(Int32 origin, Int32 extent)
   at Infragistics.Win.UltraWinGrid.DataAreaUIElement.ResizeRowScrollRegions()
   at Infragistics.Win.UltraWinGrid.DataAreaUIElement.PositionChildElements()
   at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
   at Infragistics.Win.UltraWinGrid.UltraGridUIElement.PositionChildElements()
   at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
   at Infragistics.Win.UltraWinGrid.UltraGridUIElement.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.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 EL_ExtFeatures.EasyGrid.UltraEasyGrid.OnPaint(PaintEventArgs pe) in C:\Users\kuklau\Repositories\TRENZ\easyLogic\Client\EL_ExtFeatures\EasyGrid\UltraEasyGrid.cs:line 610
   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.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Ultimately, a 'red X' shows. I've been trying to track down a similar (hopefully the same) issue that some users have been seeing every few days.
The EL_ExtFeatures.EasyGrid.UltraEasyGrid.OnPaint override simply logs whether it's called from the "wrong" thread (specifically, the 'right' thread is the one from which the parent form's instance was created). However, this code is being called on the correct thread. InvokeRequired also returns 'false'.
The PaintEventArgs contain an empty rectangle (size and position 0). Subsequent drawing calls fail in GetHdc:

at System.Drawing.Graphics.GetHdc()
at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter..ctor()
at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter..ctor(IContainer container)

[..]

at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.OnSelectedTabChanging(SelectedTabChangingEventArgs e)
at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.RaiseEvent(UltraTabControlEventId id, EventArgs e)
at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.OnManagerSelectedTabItemChanging(Object sender, SelectedTabItemChangingEventArgs e)
at Infragistics.Win.UltraWinTabs.TabManager.set_SelectedTabItem(ITabItem value)
at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.PerformDelayedInitialize()
at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)

I.e., GDI is unhappy about something. However, I'm having a hard time tracking down where this problem first occurs. Any pointers? Is it a threading problem at all?

  • 48586
    posted

    Hello ,

     

    It seems to be a threading issue. What operations you are executing in “other” thread, and how they affect the grid.  It seems to me that you are rebinding the grid, so the current band was disposed when grid is trying to be repainted and calls CellPaddingResolved which resolves to the StylePropertyCache which is null and throw this exemption. If you can provide us sample which demonstrates this I will be glad to investigate this further for you.  

     

    I am waiting for your feedback.