NonSerialized attribute not working? (problem does not involve events)

  • Thread starter Thread starter Timo
  • Start date Start date
T

Timo

When I use XML serialization to serialize MyCustomObjectCollection, all of
the public fields of MyCustomObject are being serialized, even those I've
given the <NonSerialized()> attribute.

<Serializable()> Public Class MyCustomObject

Public FieldID As String
Public ParentId As String
Public ItemId As String

<NonSerialized()> Public Name As String
<NonSerialized()> Public Data As String
..
..
..

Both Name and Data are being serialized.
What am I missing?

Thanks
Timo
 
Timo,

XML Serialization is completely different than "normal" serialization.

In this particular case you might be able to use XMLIgnoreAttribute.

Kerry Moorman
 
Thanks, Kerry, for pointing out the differences. I had ssumed the attribute
would be the same.
Timo
 
Back
Top