ReoGrid
ReoGrid copied to clipboard
ArgumentNullException on close in base.Dispose
Hello,
I've been working on a project using multiple ReoGrid components. For most of it I hadn't been getting an issue, but now I'm starting to get and ArgumentNullException when I close the form at base.Dispose.
Also, this only happens some of the time. I can't quite figure out what precisely it is that makes it occur. I know that if I start and then immediately stop it, then it nearly always happens.
Also, to add a bit more detail that may help, I'm using a Tab page component with ReoGrids in each one. It seem that the exception only happens when I don't open up each tab during runtime.
SOLVED: Okay, so I was able to ultimately solve the issue. I don't know precisely what was causing it. But I now it was caused by some controller classes That I created prior to giving the tabs focus. By only creating the controllers when the tabs containing the controls are first selected, I was able to stop the exception. I'm not sure if this will be helpful to anyone else, but I thought I'd go ahead and put it here anyway.
Here is the stack trace if it helps:
at System.Threading.Monitor.Enter(Object obj)
at unvell.ReoGrid.WinForm.GDIRenderer.MeasureCellText(Cell cell, DrawMode drawMode, Single scale)
at unvell.ReoGrid.Worksheet.UpdateCellTextBounds(IRenderer ig, Cell cell, DrawMode drawMode, Single scaleFactor, UpdateFontReason reason)
at unvell.ReoGrid.Worksheet.UpdateCellRenderFont(IRenderer ir, Cell cell, DrawMode drawMode, UpdateFontReason reason)
at unvell.ReoGrid.Views.NormalViewportController.<>c__DisplayClass23_0.<UpdateNewVisibleRegionTexts>b__0(Int32 r, Int32 c, Cell cell)
at unvell.ReoGrid.Data.Index4DArray`1.Iterate(Int32 row, Int32 col, Int32 rows, Int32 cols, Boolean ignoreNull, Func`4 iterator)
at unvell.ReoGrid.Views.NormalViewportController.UpdateNewVisibleRegionTexts(GridRegion region, GridRegion oldVisibleRegion)
at unvell.ReoGrid.Views.NormalViewportController.UpdateVisibleRegion()
at unvell.ReoGrid.Views.NormalViewportController.UpdateController()
at unvell.ReoGrid.Worksheet.UpdateViewportControllBounds()
at unvell.ReoGrid.ReoGridControl.canvasElements_VisibleChanged(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnVisibleChanged(EventArgs e)
at System.Windows.Forms.Control.OnParentVisibleChanged(EventArgs e)
at System.Windows.Forms.Control.OnVisibleChanged(EventArgs e)
at unvell.ReoGrid.ReoGridControl.OnVisibleChanged(EventArgs e)
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at unvell.ReoGrid.ReoGridControl.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Thanks for report! This possible reason of this problem is when one of ReoGrid instance is disposed, it releases some resource that is using by other ReoGrid instances.
For optimization on memory usage, some resource are shared by multiple ReoGrid instance. I will check this.
Thanks for the response! If there's any more specifics you need from me that could help let me know.
i also have this issues.
I want to fix this but I tried some cases using multiple ReoGrid instance, I can't reappear this problem. Looking forward a code project that can reappear this problem.
I had the same issue with multiple ReoGrid instances (5 instances).
Calling grid.Reset() on each instance in the Form.Closed event fixed the issue (workaround).
Using v2.1.0.
i also have the same problem when i use GridData.NewWorksheet() to create more sheets and display them.i solve it by if(GridData.Worksheets!=null&& GridData.Worksheets.Count>0) { GridData.CurrentWorksheet = GridData.Worksheets[0]; } to put the currentsheet at the first one .
I had the same issue with multiple ReoGrid instances (5 instances). Calling
grid.Reset()on each instance in theForm.Closedevent fixed the issue (workaround). Using v2.1.0.
I had the same issue and as suggested by @ncpunt calling grid.Reset() just before disposing the form solve my issue. Nevertheless, I had only one instance of the Reogrid, but the form was shown and close several times before being disposed.
I had the same issue with multiple ReoGrid instances (5 instances). Calling
grid.Reset()on each instance in theForm.Closedevent fixed the issue (workaround). Using v2.1.0.
thank you. I have the same issue and solve it by your solution.
Note: If you still see this error, the latest version delivered is from 2021 (3.0) and Nuget has this version, while the source code has version 3.1, i.e. you must recompile or use the source code to solve this bug.