I have a VB.NET class which I'm serializing via XML in an asmx file. I've added attributes to the datamember I want to ignore in serialization, but it's still returned. I also have the <DataContract()>
attribute on my class and the DataMember
attribute on all properties which should be serialized. My property declaration is:
<ScriptIgnore()> _
<IgnoreDataMember()> _
Public Property Address() As SomeObject
By adding an attribute to the backing field and converting it from an auto-property, I eventually got the proprty to stop serializing:
<NonSerialized()> _
Private _address As SomeObject = Nothing
<ScriptIgnore()> _
<IgnoreDataMember()> _
<Xmlignore()>
Public Property address() As SomeObject
Get
Return _address
End Get
Set(ByVal value As SomeObject)
_address = value
End Set
End Property
Have you tried the NonSerialized attribute:
<NonSerialized()> _
Public Property Address() As SomeObject
http://msdn.microsoft.com/en-us/library/system.nonserializedattribute.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With