The underlying connection was closed: The connection was closed unexpectedly

前端 未结 10 1034
忘掉有多难
忘掉有多难 2020-12-08 11:40

This exception is consistently thrown on a SOAP Request which takes almost three minutes to receive and is 2.25 megs in size.

When scouring the web I find all sorts

相关标签:
10条回答
  • 2020-12-08 12:31

    I hope it's not too late for answering this question.

    Try adding the following attribute on the definition of your contract interface:

    [ServiceKnownType(typeof(ReturnClass))]

    For more generic solution that allows returning polymorphic classes please refer to this post: http://www.goeleven.com/blog/entryDetail.aspx?entry=45

    0 讨论(0)
  • 2020-12-08 12:33

    I've got the same issue, and after deep investigations I found this article:

    Merrick Chaffer's Blog

    It was all related to setting the "dataContractSerializer" for both client and server. Hope this to be helpful.

    0 讨论(0)
  • 2020-12-08 12:40

    i got this error because my datatransfereobjects refered to each other in an recursive manner.

    For example:

    Customer-> (has) -> Rating Rating-> (belong to) -> Customer

    so you have to remove cycles.

    [DataContract]
    public class Rating
    {
        private Customer _customer;
        //[DataMember] // <-  EITHER HERE 
        public Customer Customer
        {
            get { return _customer; }
            set { _customer = value; }
        }
    }
    
    
    [DataContract]
    public class Customer
    {
        private long _customerID;
        [DataMember]
        public long CustomerID
        {
            get { return _customerID; }
            set { _customerID = value; }
        }
    
        [DataMember] // <- OR HERE
        public Rating Rating
        {
            get { return _rating; }
            set { _rating = value; }
        }
    }
    
    0 讨论(0)
  • 2020-12-08 12:40

    For WCF with EF, just add the following code in the context class.

    base.Configuration.ProxyCreationEnabled = false;

    0 讨论(0)
提交回复
热议问题