Obsolete Attribute and XML Serialization

   1: public class MyClass
   2: {
   3:     private string _internalProperty;
   4:     private string _newProperty;
   5:  
   6:     [Obsolete("This is no longer required, but needed for backwards compatability")]
   7:     public string Property
   8:     {
   9:         get { return _internalProperty; } 
  10:         set { _internalProperty = value; }
  11:     }
  12:  
  13:     public string NewProperty
  14:     {
  15:         get { return _newProperty; }
  16:         set { _newProperty = value; }
  17:     }
  18:   
  19: }

This is an interesting little anomaly in the way XML Serialization handles the “Obsolete” attribute on class properties when serializing to and from XML. The attribute is treated as an “XmlIgnore” attribute, meaning that the property is not serialized. It is well documented that adding the aforementioned attribute to a property in .NET 3.5 will cause this behavior, however, it is not mentioned in the same MSDN page for .NET 2.0 on the same subject.

This one caught me out. Apparently the only two ways to fix it are: to take the attributes off or use the “ShouldSerializeX” method constructs as demonstrated below…

   1: public bool ShouldSerializeProperty()
   2: {
   3:     return true;
   4: }

Leave a Comment

Unable to load client print control

UPDATE: Further information on alternative fixes has come to my attention via StackOverflow.

This new error has popped up since Microsoft released the update KB956391.

Unable to load print control error

The update is for a vulnerability in the GDI+ DLL which allowed a malicious user to execute code on the client machine (good old! – ed). The fix uses ActiveX Killbits which is a setting that Internet Explorer checks for each ActiveX control. If the Killbits are set, IE refuses to load the control.

The update set the Killbits for the version of the RS Client Print ActiveX control which is used by the version 8.0.0.0 of the ReportViewer which is referenced by RSinteract (and Report Manager). Thus the printing will not work in either.

To fix Report Manager you need to apply the ReportViewer SP1 patch and the Security Update for SQL Server SP2 (KB954606). Once this is working again you can fix RSinteract.

To fix RSinteract you need to apply another Security Update for SQL Server SP2 (KB954607).

Let us know if this fix doesn’t work for you.

Leave a Comment

First Post

This is just an idea I’m trying out, I want more people to be excited about the work that I do and I think this blog could be a good way to do that!

Bear with me while I clean up the interface and we’ll see how it goes!

Wish me luck!

Leave a Comment