Optional Elements in XML Deserialization



I am adding some properties to a class in an existing class that I would like to be considered optional for the XML Deserializer. I've added the IsNullable parameter as well as the Specified properties to no avail. My code looks like this:



<XmlElement("name")>
Public Property Name As String
<XmlElement("car", IsNullable:=True)>
Public Property Car As String

<XmlIgnore>
Public ReadOnly Property CarSpecified As Boolean
Get
Return Car <> String.Empty
End Get
End Property


I get an exception with the message "Value cannot be null. Parameter name: value"


No comments:

Post a Comment