开发者

WCF unknown field ExtensionData

开发者 https://www.devze.com 2023-02-06 20:53 出处:网络
I have this class Schedule which I return from a WCF function. When I add the service reference in visual studio, I\'m unable to see the StartTime and EndTime properties instead I get this weird Exten

I have this class Schedule which I return from a WCF function. When I add the service reference in visual studio, I'm unable to see the StartTime and EndTime properties instead I get this weird ExtensionData field. Can any one explain why this is happening?

public class Schedule
{
    public Duration SD开发者_C百科uration
    {
        get; set;
    }

    public Timeslot STimeslot
    {
        get; set;
    }
}

public class Timeslot
{
    public DateTime StartTime;
    {
        get; set;
    }

    public DateTime EndTime;
    {
        get; set;
    }

    public bool SomeFunc()
    {
    }
}


As Fredrik mentioned in the comment, the classes must be decorated with [DataContract] and [DataMember] for it to work.


...because you didn't specified the DataContract attribute, by default it used the Serializable attribute. the serializable attribute then includes all the Fields you got in your class (none, as those are properties), therefore those property information are stored in the ExtensionData.

0

精彩评论

暂无评论...
验证码 换一张
取 消