WCF Serialization - NetDataContractSerializer

I get an error when trying to send a data collection to our service. If, however, I add only one item to the collection, then it works fine. As soon as I add more than one element, I get the following error:

Using the type "SmartTrade.Shared.Common.PaymentTerm" as a get-only collection is not supported by NetDataContractSerializer. Consider labeling a type with the CollectionDataContractAttribute attribute or the SerializableAttribute attribute, or add the set property to it.

So, the main thing to note is that I can send a collection (IList <>) with one element. I have increased MaxReceivedMessageSize and MaxArrayLength to a more reasonable one.

Can anyone help me here

+5
source share
2

, . , getter setter. setter

+3

.

, System.Runtime.Serialization.IgnoreDataMemberAttribute

:

public class Whatever
{
    [IgnoreDataMember] // this won't be serialized now
    public List<string> Things
    {
        get { return _things; }
    }
}
+3

All Articles