Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

xmlserializer ignore non serializable property

$
0
0

i have a report method with an object as a entry, which simply convert the object into the xml string and insert it in a database. the entry objects have wide range and sometimes they includes non serializable properties.

i found this article: link in order to override a XmlSerializer class to ignore the properties. but the problem is I am just part of the big project and i don't know so much about the objects properties and also they increase and changes every day.

now i want to override XmlSerializer to simply ignore the non serializable properties during serialization.(i mean don't throw an exception during serialization and just ignore it and go to the another property.) also here is my serialization method:

XmlSerializer xmlSerializer =newXmlSerializer(instance.GetType());
        using (StringWriter textWriter =newStringWriter()){
            xmlSerializer.Serialize(textWriter, instance);
            str = textWriter.ToString();}

how can i do it?



Viewing all articles
Browse latest Browse all 935

Trending Articles