Click to See Complete Forum and Search --> : [Serializable] ---> seems like [IgnoreDataMember] was ignored by WCF?


THY02K
March 10th, 2009, 10:25 PM
hello

I'm using [Serializable] for my class (i.e. not labeled wih [DataContract] ---> seems like is ignored?

[I][Serializable] *** Not [DataContract]
public class A : ISerializable
{

...
[IgnoreDataMember()]
List<T> lstNames;
...
}


I called service which return A. The reason why I think IgnoreDataMember was not applied is because from SvcTraceViewer I get this message:

Type 'System.Collections.Generic.List`1
[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' with data contract name 'ArrayOfstring:http://schemas.microsoft.com/2003/10/Serialization/Arrays' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.

I need to "Ignore" the property and I've tried "IgnoreDataMember" as well as "XmlIgnore", can't get pass this. Is it because [KnownType("GetKnownType")] attribute is also ignored when you use [Serializable] instead of [DataContract] attribute?

Thanks