The underlying connection was closed: The connection was closed unexpectedly

By Anil Kumar Mar 14, 2013
The underlying connection was closed: The connection was closed unexpectedly.

The underlying connection was closed: The connection was closed unexpectedly.

Untitled.png


If you are expecting an return from called method and using WCF service, then one possible cause behind this error could be your object serialization/de-serialization problem. If your service method returns something that is not serialize-able then your proxy channel makes this error.

To avoid this, just check-

1. The return type and make sure it is serializable. You may have to put [Serializable] attribute with your class as below:

 [DataContract(Namespace = "http://codePattern.net/DataTypes/2013/03", Name = "StudentDetail")]

[Serializable]

 public class StudentDetail

   {

     [DataMember(IsRequired=true)]

        public string StudentName { get; set; }

   }

IsRequired=true; tells that the value will be present while serilizing ( its says underline property is a non-nullable value type).


2.  Make sure your enum values are matched with the values stored inside tables. This is the very critical situation because you don't expect it.


Anil Kumar

Anil Kumar is a passionate web developer, previous business owner, social executive, and a father. He has 9+ years of exposure in diverse technologies at variant roles. Anil is much inspired with Mr. Mahesh of c-sharpCor... Read more

Personal Blog: http://CodePattern.net
COMMENT USING

PREMIUM SPONSORS

Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.

Latest Blogs