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 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.
thanks,
Jim
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.
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.
Emile
Hi,
Have you found a solution to this issue? I have the same problem, and hope you can give some information.