Infosys Microsoft Alliance and Solutions blog

« October 2007 | Main | December 2007 »

November 30, 2007

Silverlight 2.0

I have been playing around with Silverlight for a while now and like all, have been eagerly waiting to get some out-of-box controls that will ease the development effort.

It is good to hear that Silverlight 2.0 will contain a good initial set of controls. The beta of this new version is expected around Q1 2008 and there is lot of speculation that RTM will be around June/July 2008.

November 20, 2007

Visual Studio 2008 Available

The must awaited Visual Studio 2008 is now available. Those who have MSDN subscriber download access, can download it from here. You can directly download the trial version from the home page itself. More details around this can be found here. In case you are facing issues in uninstalling the old Beta version and installing the new version, check here.

I am however facing issues with the new download manager. I keep getting network connection error. I will keep checking this up as I want to quickly download and start using this version of Visual Studio.

[Edited:22 Nov 2007] Full version of VS 2008 Professional Edition is available on MSDN subscriber downloads now.

November 15, 2007

Removing SmartParts from a WorkItem

A common and perhaps a little painful problem while working in CUIB (using SCSF) is disposing the smart parts from a WorkItem. If smart parts are not disposed properly one may get an exception like "Cannot access the object in its current state" and in cases where we are using TabWorkspace it is often difficult to predict the behavior.

The problem here I see is the way WorkItem is understood. A WorkItem is primarily seen as a container to manage objects. The normal tendency is to have all the smart parts added to the WorkItem and later retrieve the SmartPart from the WorkItem to accomplish certain use cases. This is not a good practice to follow; a WorkItem should be seen as something that is used to accomplish a use case e.g. In a TabWorkspace we can have creating a tab as a use case. Each use case needs to be encapsulated in a WorkItemController class. Adding and also disposing of smart parts need to be done in this class.

Let me try to elucidate how this needs to be done-Let us consider a simple use case where on click of a button a tab needs to be created in the TabWorkspace. The tab needs to display a SmartPart. Straight forward of doing this would be something like this-In the Command Handler of the button

//Add the SmartPart to the WorkItem


//Add more SmartParts as required

//Display SmartPart in TabWorkSpace

this.WorkItem.Workspaces[WorkspaceNames.LayoutWorkspace].Show(this.WorkItem.SmartParts.Get<View1>("MyView1"),new SmartPartInfo("My View","This is my view"));

The problem with this approach will be disposing of the SmartPart from the WorkItem when the use case ends - in our case closing of the tab. Of course we can remove SmartPart from the WorkItem by calling the Remove method on the WorkItem. This is not the right way to as SmartPart would not be completely disposed from the WorkItem and we will run into problems when we try add to the SmartPart again to the WorkItem and in some cases we may experience weird behavior.

The right way to tackle this problem is to encapsulate all the logic pertaining to a use case in a WorkItemController class.

Creating WorkItemController Class to define a Use Case

Create a class say MyController which inherits from WorkItemController class. WorkItemController comes with SCSF and can be found in Infrastructure.Interface Project. All the logic including adding\removing SmartParts pertaining to the use case ought to be there in this class.

class MyController : WorkItemController


        public MyController()

        { }

        public void LoadSmartParts()


//Add the SmartPart to the WorkItem


//Display SmartPart in TabWorkSpace

this.WorkItem.Workspaces[WorkspaceNames.LayoutWorkspace].Show(this.WorkItem.SmartParts.Get<View1>("MyView1"),new SmartPartInfo("My View","This is my view"));



Now in the Command Handler of the button create an instance ControlledWorkItem – this can be found in Infrastructure.Interface and add this instance to the WorkItem

ControlledWorkItem<MyController> myController = this.WorkItem.WorkItems.AddNew<ControlledWorkItem<MyController>>("MyController");


Disposing SmartParts

Subscribe to the tab close event and in the event subscription code dipose the SmartPart and finally the WorkItem itself.

//Dispose method in the Controller class

//Disposes all the SmartParts from the workItem

class MyController : WorkItemController


        public void DisposeSmartParts()


IEnumerator<KeyValuePair<string, object>> smartPartCollection = this.WorkItem.SmartParts.GetEnumerator();

            List<object> spCollection = new List<object>();

            while (smartPartCollection.MoveNext)


KeyValuePair<string, object> namedValue = smartPartCollection.Current;



            for (Int16 i = 0; i <= spCollection.Count - 1; i++)



            if (spCollection(i) is IDisposable)







Call this method in the tab close event subscription code

ControlledWorkItem<MyController> myController = this.WorkItem.WorkItems.Get<ControlledWorkItem<MyController>>("MyController");

//Dispose the SmartParts from the WorkItem


//Dispose the WorkItem


This ensures all the SmartParts and subsequently the WorkItem is disposed correctly.




November 12, 2007

Visual Studio 2008 RTM

Visual Studio 2008 is expected to RTM later this month. It should be available on MSDN Subscriber download, but the general off-the-shelf availability is still early next year.

November 1, 2007

It is Today - 1st Nov 2007

You would be aware of the expiring of VS 2008 Beta 2 VPCs today. If you have watching the VS Developer Center, you would have noticed the new updates on this. Jeff has mentioned in his blog about what happens with the existing VPC and mentions the 3 alternatives going forward

  • Upgrade the base OS with valid license
  • download the newly published VPC images from here
  • continue to work with the existing VPC and keep rebooting every 1-2 hrs.

Since downloading the 8 files, required for the VPC (not including the base image), took quite a bit of time for me, I will continue to use the existing VPC as is, as I can live with the reboot requirements for now.

Subscribe to this blog's feed

Follow us on

Blogger Profiles

Infosys on Twitter