Adrian Hara

Working through the .NET maze

  Home  |   Contact  |   Syndication    |   Login
  42 Posts | 0 Stories | 83 Comments | 10 Trackbacks

News

Archives

Post Categories

Wednesday, April 29, 2009 #

This has probably been covered in some tutorial videos or "silverlight 3 what's new"s, but due to the fact that I spent the better half of an hour googling about ways to do it, I guess also posting it here for reference won't hurt.

Problem: when calling a WCF service from Silverlight 2, if the service throws an exception, in Silverlight you get a CommunicationException with some mumbo-jumbo in it, not the actual exception or Fault declared on the service.

Fix: in Silverlight 3 there is built-in support on the client-side for FaultException and FaultException<T>. All you need to do it tweak the WCF service a bit so it returns a 200 response code, instead of the default 500 response code, so you actually get the FaultException, as explained here: http://msdn.microsoft.com/en-us/library/dd470096(VS.96).aspx

Also, some more info on this and other new stuff in SL3: http://blogs.msdn.com/silverlightws/archive/2009/03/20/what-s-new-with-web-services-in-silverlight-3-beta.aspx