In our application different views can be added (via a 'view' menu option) to the layout, but each view should not exist more than once. This is implemented using the following code:
{
TView view = default(TView);
{ view = WorkItem.SmartParts.Get<TView>(viewId); }
else { view = WorkItem.SmartParts.AddNew<TView>(viewId); }
}
If I select from the view menu two different views, they both are added to the layout. If I select one of them again from the view menu, the code above makes sure that I get a reference to the existing view. This is visible by the corresponding view getting selected.
When I shut down the application, I use the SaveAsXml method from the UltraDockWorkSpace.
When the application is started again, first all views that where open previously are added to the smart part list (with the code above).
Then the LoadFromXml method from the UltraDockWorkSpace is called. Now everything is visible just as it was when shutting down.
So far so good.
However, if I now select one of the open views via the view-menu, I would expect the same behaviour as before, but I now very often get the following error message:
System.ArgumentException was unhandled Message="Key not found\r\nParameter name: key" Source="Infragistics2.Shared.v8.2" ParamName="key"
It looks like each smartpart has a key value, and there's a mismatch between the views that are opened at startup, and how they are registered in the xml file. But can this behaviour be switched off? Or am I doing something wrong?
Not that the 'Name' of a specific view when it is added to the SmartPart list is always the same.
Hello Mike
If I remove the LoadFromXml call, everything works perfectly (only the positions of the views are not as they were of course). So it definitely has to do with reading the layout from xml. The strange thing is that when there would be some kind of mismatch, you would expect an error at application startup. But no error occurs, and the whole layout looks exactly as it was at the previous shutdown. Only when I select one of the visible views (via the view menu) the error occurs.
Thanks for the reply, and I will submit this to the support group.
Emile
If you remove the call to LoadFromXml, does the problem still occur? If so, it sounds like a bug in your logic which reloads the previously open smart parts. If not, it could be a bug with the dock manager and I would recommend submitting the issue to the support group: http://es.infragistics.com/gethelp.