Friday, December 4, 2009

Deploying WCF service to Azure CTP Platform

To deploy a WCF service (ASPnet Web Role) on Azure platform is fairly straightforward.

Once testing the solution on Development fabric, replace the &<;endpoint address="" with staging or production uri in the ServiceReferences.ClientConfig file. Publish the webrole project. This should generate application package file and configuration file to be deployed on Azure platform. Leave the port number to be default since Azure would run the webservice under port 80.

Tuesday, December 1, 2009

Compile error 'Cannot implicitly convert type 'System.Collections.ObjectModel.ObservableCollection'.

While trying to call a WCF service and assigning a resultant array to a local variable, you may encounter an compile error 'Cannot implicitly convert type 'System.Collections.ObjectModel.ObservableCollection'.

How to resolve this error.
below might be code you might be trying to compile

void proxy_GetUOSListCompleted(object sender, SilverScreens.SilverServiceProxy.GetUOSListCompletedEventArgs e)
{
//Here result returns a List object
SilverServiceProxy.UOS[] ResultUOS = e.Result;
UOSList.ItemsSource = ResultUOS;
}

Following are the steps to resolve it.

Right click on Service Reference in your Webapplication. In the context menu select "Configure Service Reference...", choose in the combobox of collection type: System.Array.

The other work around is to change the code to use ObservableCollection collection, since ObservableCollection also implements suitable property changed notification mechanism such as the INotifyPropertyChanged interface

void proxy_GetUOSListCompleted(object sender, SilverScreens.SilverServiceProxy.GetUOSListCompletedEventArgs e)
{
//Here result returns a List object
List&; = (List&;).Result.ToList();
UOSList.ItemsSource = ResultUOS;
}

One other observation was that while compiling the above code resulted in the compile time error that ToList() operator could not be associated. To resolve this issue, add the system.linq namespace statement.