Exception in Silverlight

Posted by Santoshkumar under Silverlight on 7/12/2011 | Points: 10 | Views : 1257 | Status : [Member] | Replies : 1
I am totally confusing. How handle in silverlight. I am using WCF i wrote fault exceptions in wcf. i have created proxy. How the silverlight handle those exception. give me any example if possible.

plz help

thanq




Responses

Posted by: Vuyiswamb on: 7/17/2011 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
in Silverlight we do Async Calls

So the first part when calling the service after you generated a Proxy should something like this

business.AddContactNumberAsync(model);
business.AddContactNumberCompleted += new EventHandler<AddContactNumberCompletedEventArgs>(business_AddContactNumberCompleted);


and this(AddContactNumberCompletedEventArgs) will be generated for you and to do error handling on it or bring the error from the service it should be something like this


        void business_AddContactNumberCompleted(object sender, AddContactNumberCompletedEventArgs e)

{
if (e.Error == null)
{
if (e.Result == "")
{
MessageBox.Show("Successfully Added");
this.DialogResult = true;


}
else
{
MessageBox.Show("Contact was not Added");
}
}
else
{
MessageBox.Show("Service not Available");
}
}


as you can see we check if the Error property is null, if its not null we show some generic error and probably log the error



Thank you for posting at Dotnetfunda
[Administrator]

Santoshkumar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response