Wednesday, April 29, 2009

WCF and Silverlight debugging

As part of my latest updates to my current project, I made a change to the underlying WCF service that provides much of the information to our Silverlight application. In one of my DataContract classes, I started passing a child class to one of its DataMembers (i.e. the DataMember is a property on Foo, I passed in a Bar which is a subclass of Foo). Then, when Silverlight called the asynchronous version of that method, I started getting an ambiguous error: "The remote server returned an error: NotFound"

I stepped through both the Silverlight side and my WCF side - no errors apparent either place. However, just after the return statement in WCF and method exit, the Silverlight's service reference would pop up the "NotFound" error. Strange, I thought... what's the problem?

Other web searched seemed to direct me to update the buffer size, to delete and re-add the service reference, all to no avail. Finally, I changed the type on my datacontract's datamember to be the subclass instead of the parent class. Voila! Like magic, everyone's happy again. I'm not certain of the mechanics behind this failure- it seems like it should be allowable. In any case, if you hit this error, check the types on your data members as well - see if there's a more specific class you could be using instead.

Wednesday, April 22, 2009

Warning signs

Writing effect warning signs lesson #1: If the major reason to heed the warning doesn't get them to pay attention, give them a minor reason, too.

Not only will this kill you, it will hurt you the whole time you are dying

Tuesday, April 21, 2009

Unit testing with Silverlight

I'm in favor of test driven development. The sooner you find bugs in the product cycle the less costly the are to fix, afterall. Currently, I'm working with Visual Studio 2008 SP1 with the Silverlight tools installed - my current project is a multi-tier system with DB backend, WCF web services, and a Silverlight client.

However, when I added a test project and attempted to navigate to the Code Coverage tab of my test run config, the run config editor simply closed. I tried a few of the usual suspects - devenv /resetsettings, devenv /resetuserdata, repairing my Silverlight VS add-in installation - all to no avail.

Then, after one MSDN search, I discovered that this is a known issue. The fix is available here and it's working for me so far. Hooray for test enablement!