Problem creating multiple instances of smartpart

Topics: CAB & Smart Client Software Factory
Aug 22, 2006 at 6:21 AM
originally posted by: nspvarma


I had designed a smartpart named "MyContainer" which has a zoneworkspace by name "zoneworkspace1" with two zones, to act as a container for showing two smartparts in these zones at runtime.

Now when i add this smartpart to the workitem more than once with different ID's, while adding the second instance it throws an error "zoneworkspace1" already exists.

Code in workItem:

this.Items.AddNew<MyContainer>("First"); //Works fine.

this.Items.AddNew<MyContainer>("Second"); // Throws exception that zoneworkspace1 already exists.

Basically, the problem i see is when you add a workspace to a smartpart at design time and then adding two instances of the smartpart with different ID also throws error for the internally contained workspaces that they are already present in the workitem.

What is way to reuse smartparts containing workspaces added at design time in an application?

Thanks in advance for your valuable suggestions.

Thanks and Regards,
Aug 22, 2006 at 12:15 PM
originally posted by: ChrisHolmes

You can't have two of the same workspace with the same name. A workspace is designed to be a unique instance in the hierarchy so that any other WorkItem can reference it and add SmartParts to it. Obviously, changing the name on the second instance of the Workspace changes your ability to have WorkItems reference it correclty. So what you need to be asking yourself is, "Why do you need two copies of the same workspace?"
Aug 24, 2006 at 1:05 AM
originally posted by: yonis

Ok Chris. I have same problem. But my container re-created several times. And i can't rename a workspace name at real-time ). I solve this problem using event handler for SmartPartClosing where i remove workspace from WorkItem, but i think that CAB do it this. =)