The given key was not present in the dictionary error


Author
Message
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi,



I am working with a DataGridView in a child form, if I cancel the childform with the follwing code:



DialogResult = Windows.Forms.DialogResult.Cancel




Then I get the following exception:





KeyNotFoundException

The given key was not present in the dictionary.



Source : mscorlib



Stack Trace:

at System.ThrowHelper.ThrowKeyNotFoundException()

at System.Collections.Generic.Dictionary`2.get_Item(TKey key)

at MicroFour.StrataFrame.Business.BusinessLayer.get__CurrentDataTable(Boolean IsSharedTable)

at MicroFour.StrataFrame.Business.BusinessBindingSource.RemoveBOHandlers()

at MicroFour.StrataFrame.Business.BusinessBindingSource.Dispose(Boolean disposing)

at System.ComponentModel.Component.Dispose()

at System.ComponentModel.Container.Dispose(Boolean disposing)

at System.ComponentModel.Container.Dispose()

at CardTrackingSystem.frmActivateCardsItems.Dispose(Boolean disposing) in E:\Visual Studio 2008 Projects\StrataFrame\Card Tracking System Projects\CardTrackingSystem.NET\CTS Solution\Card Tracking System\Dialogs\Transaction Forms\Activate Cards\frmActivateCardsItems.Designer.vb:line 10

at System.Windows.Forms.Form.Close()

at MicroFour.StrataFrame.UI.Windows.Forms.ChildFormDialog.ShowDialog(Object[] Arguments)

at MicroFour.StrataFrame.UI.Windows.Forms.ChildFormDialog.ShowDialog()

at CardTrackingSystem.frmActivateCards.cmdAddCards_Click(Object sender, EventArgs e) in E:\Visual Studio 2008 Projects\StrataFrame\Card Tracking System Projects\CardTrackingSystem.NET\CTS Solution\Card Tracking System\Dialogs\Transaction Forms\Activate Cards\frmActivateCards.vb:line 800

at System.EventHandler.Invoke(Object sender, EventArgs e)

at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)

at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)

at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)

at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)

at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)

at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)

at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)

at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.ScrollableControl.WndProc(Message& m)

at System.Windows.Forms.ToolStrip.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)







The DataGridView is being populated with a BBS and the error only happens if the grid has some data. I don't know what "Key" it may be looking for? Also I would like to note that the BO assigned to the BBS has come Custom Field Properties which are not used in the DataGridView.

Edhy Rijo

Replies
Peter Jones
Peter Jones
Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi Trent,



I just want to confirm that you guys are 'on the case'. We have also commented out that line of code that Bill highlighted and now our app works ok with SF 1.7 and DX 9.1.5. but what are the side effects (if any) of doing this?



Cheers, Peter
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
It looks like this is ONLY happening on DevExpress grids version 9.x and greater. So something apparently changed. Instead of getting in contact with DevExpress, etc. we went ahead and made a code change in the event that another 3rd party control references an IBindingList implementation during disposal.



Ultimately this is a simple fix, but the reason for all of the confusion was due to different versions of a 3rd party control acting different ways. The next minor release posted will include this fix, but you can go ahead and change the source if you like temporarily. You WILL NOT have to maintain this source as it has already been changed. But the issue is that the _BusinessObject has already been disposed, thus when the grid implicitly attempts to dispose of the data source, an error occurs. Here is the code as it should be to resolve the error:



BusinessBindingSource, RemoveBOHandlers()



'''

''' Removes the necessary event handlers from the business object.

'''


'''

Private Sub RemoveBOHandlers()

'-- Make sure that the BO has a reference

If _BusinessObject Is Nothing Then Return



Try

'-- Remove the necessary handlers

RemoveHandler Me._BusinessObject.AfterAddNew, AddressOf BusinessObject_InternalAfterAddNew

RemoveHandler Me._BusinessObject.BeforeAddNew, AddressOf BusinessObject_InternalBeforeAddNew

RemoveHandler Me._BusinessObject.InternalAfterAddNew, AddressOf BusinessObject_InternalAfterAddNew

RemoveHandler Me._BusinessObject.CurrentDataTableRefilled, AddressOf BusinessObject_CurrentDataTableRefilled

RemoveHandler Me._BusinessObject.CurrentView.ListChanged, AddressOf BusinessObject_CurrentView_ListChanged

RemoveHandler Me._BusinessObject.Navigated, AddressOf BusinessObject_Navigated

RemoveHandler Me._BusinessObject.IsDirtyChanged, AddressOf BusinessObject_IsDirtyChanged

Catch ex As Exception

End Try

End Sub

Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Trent,



I am happy to say that I made the changes posted before to the BusinessBindingSource, RemoveBOHandlers() and that fix the error or as you would say "Smoke it!!!!".



WARNING.... I just tested it once Hehe

Edhy Rijo

Jeff Pagley
Jeff Pagley
Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)
Group: StrataFrame Users
Posts: 223, Visits: 893
Hi SF Team,

I understand where to make the change but I am running VS 2005 and the Microfour Strataframe.sln is not loading.   I have loaded the Microfour Strataframe Inherited IU project and updated the DevExpress references to v9.1.5 and created the new DLL successfully.  I tried loading the Microfour Strataframe Business project, but I get over 100 errors.  I am not sure what to do now.  What are the steps I need to take to implement this fix or will you post a new dll with this fix?

Thanks,

Jeff

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Edhy Rijo - 16 Years Ago
Trent L. Taylor - 16 Years Ago
Edhy Rijo - 16 Years Ago
Trent L. Taylor - 16 Years Ago
Edhy Rijo - 16 Years Ago
Edhy Rijo - 16 Years Ago
Trent L. Taylor - 16 Years Ago
Larry Caylor - 16 Years Ago
Edhy Rijo - 16 Years Ago
Trent L. Taylor - 16 Years Ago
Bill Cunnien - 16 Years Ago
                         Here are the exception details (if they help):
...
Bill Cunnien - 16 Years Ago
                             A bit more info...I blew away the BOs on a specific window that was...
Bill Cunnien - 16 Years Ago
                                 Since I have only one major active project at the moment, I decided to...
Bill Cunnien - 16 Years Ago
                                     1.6.7 was available. I hit the link to download, but I left the...
Bill Cunnien - 16 Years Ago
                                         I opened the source code in VS2008 and built the solution. No errors....
Bill Cunnien - 16 Years Ago
                                             I decided to edit one of the offending windows: Inventory Adjustments....
Bill Cunnien - 16 Years Ago
                                                 Bill,

Sorry for the delay here, we have been fighting some...
Trent L. Taylor - 16 Years Ago
                                                     Hi Trent,

I figured you were busy wrapping up the release....
Bill Cunnien - 16 Years Ago
                                                         Before you spend too much more time, just drag a DataGridView onto...
Trent L. Taylor - 16 Years Ago
                                                             I dropped a DataGridView onto the form and disconnected the DevEx grid...
Bill Cunnien - 16 Years Ago
                                                                 I attempted to recreate the error for you in a sample application....
Bill Cunnien - 16 Years Ago
                                                                     The C# app sample is complete. There are no errors in that sample...
Bill Cunnien - 16 Years Ago
                                                                         References...how do I cleanup the references? I attached a window...
Bill Cunnien - 16 Years Ago
                                                                             Attached are two assemblies and their version tabs. Is the...
Bill Cunnien - 16 Years Ago
                                                                                 When you installed SF 1.7.0, it did not clear out all of the 1.6.0...
Trent L. Taylor - 16 Years Ago
                                                                                     So I go to uninstall SF and start over (again) and I get this...see...
Bill Cunnien - 16 Years Ago
                                                                                         Where are you getting this? Most likely you are just not getting all...
Trent L. Taylor - 16 Years Ago
                                                                                             [quote]Where are you getting this?[/quote]

It popped up...
Bill Cunnien - 16 Years Ago
                                                                                     [quote][b]Trent L. Taylor (07/29/2009)[/b][hr]When you installed SF...
Bill Cunnien - 16 Years Ago
                                                                                         Btw, if you are interested, the SharedTableKey being passed to...
Bill Cunnien - 16 Years Ago
Keith Chisarik - 16 Years Ago
Trent L. Taylor - 16 Years Ago
Jeff Pagley - 16 Years Ago
Bill Cunnien - 16 Years Ago
Bill Cunnien - 16 Years Ago
Trent L. Taylor - 16 Years Ago
Trent L. Taylor - 16 Years Ago
Bill Cunnien - 16 Years Ago
Peter Jones - 16 Years Ago
Trent L. Taylor - 16 Years Ago
Bill Cunnien - 16 Years Ago
                     Or...send me a sample and save the energy. I can change the...
Trent L. Taylor - 16 Years Ago
                         I worked up a sample yesterday but it did not fail like my production...
Bill Cunnien - 16 Years Ago
                             OK, thanks.
Trent L. Taylor - 16 Years Ago
                                 Nothing is easy. What a killer downgrading to v8.2.10. So many...
Bill Cunnien - 16 Years Ago
                                     This is not funny. I am getting the same error. The same...
Bill Cunnien - 16 Years Ago
                                         Is the following code necessary (red highlight)? If so, why?
...
Bill Cunnien - 16 Years Ago
                                             I commented out that code and everything works just fine. I am...
Bill Cunnien - 16 Years Ago
                                                 [quote][b]Bill Cunnien (07/30/2009)[/b][hr]...I am not going to take...
Bill Cunnien - 16 Years Ago
                                                     Ok...I got there. I am now running on SF 1.7.0 and DevEx 9.1.5. Of...
Bill Cunnien - 16 Years Ago
Peter Jones - 16 Years Ago
Trent L. Taylor - 16 Years Ago
Edhy Rijo - 16 Years Ago
Jeff Pagley - 16 Years Ago
Jeff Pagley - 16 Years Ago
Trent L. Taylor - 16 Years Ago
Ross L. Rooker, Sr. - 16 Years Ago
Edhy Rijo - 16 Years Ago
Trent L. Taylor - 16 Years Ago
                     Hi
I just tried to upgrade my SF 1.6.6.9 to 1.7.0.6. Very...
ChanKK - 15 Years Ago
                         Additionally, I am using DevExpress 9.1.4
ChanKK - 15 Years Ago
                             Attached sample project.
ChanKK - 15 Years Ago
                                 Wow...this is an ironic twist of fate. A while back we made a number...
Trent L. Taylor - 15 Years Ago
                                     Hi,
Thank you. I am downloading, will inform you once testing...
ChanKK - 15 Years Ago
                                         Sounds good, Chan. Thanks. :)
Trent L. Taylor - 15 Years Ago
                                             Hi,
I have tested and found new issues.

[u]Testing...
ChanKK - 15 Years Ago
                                                 This is on my radar and I am looking into this. Sorry for the delay.
Trent L. Taylor - 15 Years Ago
Hugo R. Figueroa - 15 Years Ago
Hugo R. Figueroa - 15 Years Ago
Trent L. Taylor - 15 Years Ago
     Thank you.
Hugo R. Figueroa - 15 Years Ago
Hugo R. Figueroa - 15 Years Ago
             Glad to hear it! :)
Trent L. Taylor - 15 Years Ago
abenge - 15 Years Ago
Dustin Taylor - 15 Years Ago
abenge - 15 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search