Can anyone shed some light on this error?
System.ArgumentException: {"Key not foundParameter name: key"}
Message:Key not foundParameter name: key
StackTrace: at Infragistics.Shared.KeyedSubObjectsCollectionBase.GetItem(String key) at Infragistics.Win.UltraWinGrid.ColumnsCollection.get_Item(String key) at NBSControls.BondSourcesUsesBase.ugSources_InitializeLayout(Object sender, InitializeLayoutEventArgs e) in C:\Documents and Settings\mhsueh\My Documents\Visual Studio 2005\Projects\DFAST3\Controls\District\BondSourcesUsesBase.vb:line 29
Yes,
Some code in your InitializeLayout event handler is trying to access an object in a collection by a key that does not exist. Probably a column.
That was my first thought, but I have been through the tools multiple times, and compared values in the toolbar customize with values in the <formname>.designer.cs to make sure everything was in sync, and the error still occurs.
What does the "toolbar customize" have to do with it? The error message here is referring to the Columns collection in a WinGrid control.
Have you tried stepping through the InitializeLayout code to see what line of code the error is occurring on?
This error message is very clear and very common. There's no mystery about it. Your code is definitely trying to access a column in the grid using a Key that does not exist in the collection.
If the Debugger doesn't break on the exact line of code that's causing the issue, then you may need to set Visual Studio to break on all run-time exceptions - the error is probably being caught by the grid and masking the true source of the error.
I am getting this error on the toolbar, not the wingrid. I am looking for a solution, and following all threads. This began yesterday when I went through and changed some captions on toolbar buttons, compiled the app, ran it, and the new caption values were not present at runtime. I then went through and updated the keys for each toolbar button to match the caption. After that change, things go boom! I keep getting this "key not found" error. I have copied and pasted, etc. to make sure they all have the same verbage and the problem continues. I admit, I am new to your controls. I started this job 2 months ago and I am working to make requested mods to an existing application. Feel free to email me off-line.
FYI, I also replied to the "Key not found for UltraToolbar" posting. That may help you understand what I am up against.
The error message you posted here clearly indicates that the exception is occurring in the InitializeLayout event of the grid. So some code in that event is referring to an object in a collection by key and that key does not exist in the collection. The message specifically refers to the columns collection.
So if you are getting an exception on the toolbar, also, then the call stack you posted here must be the wrong one.
Did you try breaking on all exceptions like I suggested?
Yes. I get numerous exceptions that have nothing to do with the UltraToolBar until I eventually hit the break I put in to step through the first line that throws the "key not found" exception. This is really perplexing as if I put the real key value in, it falls over. If I put back in the original key value, it works, shows the caption values that no longer exist in the toolbar. This should have been very simple. I have a task to take all of the times "Organization" is used and replace that with "Account". I have scrubbed and searched every file in that project's directory and cannot find any places where "Organization" is still in any property of the UltraToolBar control in question. However, when I execute the code with this line...
toolbarManager.Tools["Open Tickets for Account"].ToolClick += new ToolClickEventHandler(TicketList_ToolClick);
The app falls over with the key not found error. Yet if I change it back to...
toolbarManager.Tools["Open Tickets for Organization"].ToolClick += new ToolClickEventHandler(TicketList_ToolClick);
it runs and when you hover over any of the buttons that have had, both their key and caption values renamed to account, they still show as Organization. I have ran "Clean Project", deleted all object, binaries, etc., recompiled and still get the same behavior. How can the toolbar manager keep this information when every text entry has been modified. I even saved the toolbar configuration to a XML file, modified all occurrences of Organization, reloaded the configuration and verified the values were modified in the toolbar manager. This is getting very frustrating so any ideas will be greatly appreciated.
Can this type of issue be published in a KB article?
Found it. Someone had a .LoadFromXML, that got an "encrypted XML string" from the database that over wrote any settings you did in the designer. I commented that line out and things "not go boom". Thanks for pointing me in the right direction. I am going to close that support ticket also.
Did you try searching for the .Load method of UltraToolbarsManager? You could be saving and loading the toolbars to binary, in which case your text search would not have found it.
FYI, I submitted this to support just now. Case Number: CAS-31347-KCMWBU
I thought about that as a possibility, but I stepped all of the code, plus searched for the phrases used in the tool tip through out the entire solution and could not find a match. I used NotePad++, "find in files" to do the search, since I do not have much luck with Windows search finding these types of things. I even went through the database to see if there were some, "user settings" and came up empty. I really picked a bad time to give up drinking. :-) Is there possibly a cache file, or some type of settings file the components have?