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.
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://ko.infragistics.com/gethelp.
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
Hi,
Have you found a solution to this issue? I have the same problem, and hope you can give some information.
thanks,
Jim
Unfortunately I don't have a solution yet. At this moment I use a try-catch (with an empty catch) around the 'WorkItem.Workspaces[workspaceName].Show(view)' call, so at least my application doesn't crash.
It's ok for now. I'm busy with some other issues, but I want to dive into this again soon.
If you have close a View before you saved the layout. The view is actually hide. So next time, when the layout is loaded, you might make sure that view, which is hide, is not loaded before applying the layout. Otherwise, next time when you start up the view, there are possible you will get an error.
This a workaround I have done some times ago, but not sure if it is still working.
The problem get resolved automatically after we upgrade to v8.3.
Did anybody happen to find a solution to this problem? I am also having the same problem now.