Print Page | Close Window

ArgumentNullException when calling Dispose

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1445
Printed Date: 23-Apr-2025 at 6:04pm


Topic: ArgumentNullException when calling Dispose
Posted By: f3rland
Subject: ArgumentNullException when calling Dispose
Date Posted: 26-Aug-2009 at 12:36pm
Using : DevForce 3.6.7.1 & DevExpress 9.1.3

I get an exception when trying to dispose a IdeaBlade.UI.WinForms.DevExpressControls.XtraGridBindingManager object :

   à System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
   à System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
   à System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
   à IdeaBlade.UI.WinForms.DevExpressControls.XtraGridColumnBinder.UnRegisterEvents(RepositoryItem pRepositoryItem)
   à IdeaBlade.UI.WinForms.DevExpressControls.XtraGridBindingManager.Dispose(Boolean disposing)
   à System.ComponentModel.Component.Dispose()

How to properly dispose XtraGridBindingManager object?


-------------
F3



Replies:
Posted By: kimj
Date Posted: 01-Sep-2009 at 7:48pm

Dispose will work correctly if you construct the XtraGridBindingManager using the constructor which accepts an IContainer, e.g.,

   myXgbm = new XtraGridBindingManager(this.components);
 
This is actually the constructor used by the XtraGridBindingManager designer when it auto-generates code.  Using this constructor, dispose will also automatically be called when the container is disposed.
 
(The fact that Dispose does not work correctly when other constructors are used is a bug.)



Print Page | Close Window