IPAddress class serializable?

Back in 2002 I posted a question in Usenet about the IPAddress class being serializable, but not serializing in ASP.NET. I just found the post, and noticed that no one responded with the reason why. So, here it is:

There are two types of serialization in .NET: System.Runtime.Serialization and System.Xml.Serialization. Runtime serialization uses the serializable attribute while XML serialization does not. Since ASP.NET uses XML serialization, the attribute was irrelevant.

The error I received was:

System.Net.IPAddress cannot be serialized because it does not have a default public constructor

One of the requirements of the XmlSerializer is that the class it is trying to serialize must have a default public constructor.

9 comments on “IPAddress class serializable?

  1. Ok, so now it’s April of 2009 and you still can’t serialize an IPAddress with XmlSerializer. Now what?

Comments are closed.