March 2009 Blog Posts

Shizxaml – Silverlight’s old codename?

According to Mike Harsh in his Mix talk on Silverlight 3.0 – Out of Browser, before silverlight was WPF/E, internally Microsoft were calling it Shizxaml. I so wish this had been the product name. “Lets shizxaml that sucker” and the like. Brilliant!

DataContractJsonSerializer and DateTime values

In using the DataContractJsonSerializer beware of DateTime instances which have been instantiated as non-UTC. If you declare without explicitly assigning a DateTime you get the same as default(DateTime), this is 01/01/01 00:00:00 (0 ticks) with a DateTimeKind of Unspecified. When the DataContractJsonSerializer looks at this value (or a Local datetime), it will try to convert it to UTC by subtracting the time zone ala UTC standard notation, this results in a date time that is less that 0 ticks and an out of range exception if you are west of GMT. The solution is to always instantiate as UTC...

WCF Collections with Payload via Surrogates

Previously I posted about the problem with WCF and collection which have a payload in them. I came across this problem again when using the DataContractJsonSerializer and thought I would look at possibilities to resolve it. If you have implemented the IXmlSerializable interface then you are kind of stuffed because the Json serializer will emit json with a bunch of xml in the middle….nice! It is really useful to reference sowmy’s post on the precedence of serializable classes in the Data Contract family of serializers. Instead you can use a Surrogate. This is a class which implements IDataContractSurrogate...