Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to exclude some members of a type from XmlSerializer serialization?

I have some public members I don't want to be serialized, was wondering if there is an attribute for it?

like image 248
Joan Venge Avatar asked Oct 22 '09 18:10

Joan Venge


People also ask

What occasions the XML serialization throws an exception?

XmlSerializer throws exception when the type belongs to an assembly with no location property set #24614.

How to not serialize a property in c#?

When using the BinaryFormatter or SoapFormatter classes to serialize an object, use the NonSerializedAttribute attribute to prevent a field from being serialized. For example, you can use this attribute to prevent the serialization of sensitive data.

How does the XmlSerializer work C#?

The XmlSerializer creates C# (. cs) files and compiles them into . dll files in the directory named by the TEMP environment variable; serialization occurs with those DLLs. These serialization assemblies can be generated in advance and signed by using the SGen.exe tool.

Is XmlSerializer thread safe?

Since XmlSerializer is one of the few thread safe classes in the framework you really only need a single instance of each serializer even in a multithreaded application.


1 Answers

You are looking for XmlIgnore

like image 77
Ryan Rinaldi Avatar answered Nov 14 '22 23:11

Ryan Rinaldi