Monday, 17 August 2009

Hotfix breaks live code

I have spent near enough all of today trying to fix a system that was broken by the automatic application of a Microsoft hotfix, specifically KB958484 Application Compatibility Update.

The first that I knew of any issue was when this morning discovered that one of our live sites had stopped working around 3am Sunday morning.  A little digging turned up that a windows update had been applied at this time, KB958484.

This gem of a hotfix changed the behaviour of the XmlSerializer so that where as before the hotfix if a class had a read only property the serializer just ignored the property, now the serializer threw an exception saying Unable to generate a temporary class (result=1). error CS0200: Property or indexer 'Person.Id' cannot be assign to -- it is read only

A bit of googling showed that I was not the only person experiencing problems in relation to this but a lot of the solutions weren’t very enlightening many mentioning that you needed to  use *Specified, and googling that didn’t turn up anything immediately apparent.

What it comes down to is using the attributes specifically related to Xml serialization like [XmlElement], now since the properties that were being complained about were public read only i.e. couldn’t be used for deserialization simply adding the attribute [XmlIgnore] resolved the issue.

No comments:

Post a Comment