An object with this ID already exists

Topics: CAB & Smart Client Software Factory
Nov 22, 2006 at 5:07 AM
originally posted by: mansica

I'm using a tab workspace in my smart client and one use case is to open a purchase.
It should be possible to open two different purchases and add both these to the tab workspace.

The purchase view has underlying smartparts(user controls) which are automagically added to its workitems collection for smartparts when loading it.
Since these smartparts are added with its name as id I get "An object with this ID already exists" error.

When we add the purchase view to the workitem we use a unique id as id for the smartpart but for the underlying smartparts we are not able to do control this or are we?

Shouldn't it be possible to have two instances of the same view in a workspace or am I using the CAB framework all wrong?
Nov 24, 2006 at 12:35 AM
originally posted by: mansica

I have come up with two possible solutions.

1. Create a new workitem for each time I open the same view again.
2. Somehow alter the way the CAB-framework adds underlying smartparts to the smartpart collection in current workitem.

I don't know if either of these solutions are any good and would very much appreciate if someone had any input on this.
Nov 24, 2006 at 2:09 AM
originally posted by: Shiraz

We have had the same problem. The root cause of the problem is that two smartparts with the same name exist within the same context. In this case the context is the workitem.

The way we got around this problem was to create a sub work item that owned each view.

For example, if you have a customer screen that had 2 addresses, and the address view is a smartpart, you get the above problem. To solve it you must create two sub work items, that each owns one address view, therefore no collision.

If your problem is that you cannot open 2 customers at the same time. Then you need to create a customer module work item, this will have the job of opening a customer workitem for each customer you open, and giving each workitem a unique name.