Datacontract exception. Cannot be serialized

前端 未结 6 874
天命终不由人
天命终不由人 2021-01-01 08:28

I have the following WCF DataContract:

[DataContract]
public class Occupant
{
    private string _Name;
    private string _Email;
    private string _Organi         


        
6条回答
  •  时光说笑
    2021-01-01 09:05

    Because you have provided one or more initializing constructors, you will also need to add a parameterless (default) constructor.

    i.e. You need to add:

    [DataContract]
    public class Occupant
    {
        // *** Needed only for Serialization
        public Occupant() {}
        ...
    

    This is because the default constructor disappears when you add an explicit constructor.

    [The issue isn't with the method returning List, since methods aren't serialized).]

提交回复
热议问题