WCF method called twice

前端 未结 7 1099
一个人的身影
一个人的身影 2021-02-02 15:41

I have a web service which is returning data to the desktop application. The problem I am having is, when the web service returns small volume of data everything works fine but

7条回答
  •  萌比男神i
    2021-02-02 16:32

    I recently had this issue.

    It turned out that analyzing the WCF log as written by the System.Diagnostics.XmlWriterTraceListener yielded a problem with the data contract I had set up.

    I am returning Dictionary (Side Note: Yes, I know this is really bad!, but I am young and need the money). I forgot to include the [KnownType] attribute on the return value for the DataContract:

        [DataContract]
        [KnownType(typeof(Dictionary))]
        [KnownType(typeof(Dictionary))]
        [KnownType(typeof(Dictionary>))]
        public class MyCoolObject: ICoolObject
        {
    [DataMember]
            public Dictionary Results
            {
                get { return _results; }
                set { _results = value; }
            }
        }
    

提交回复
热议问题