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.


Ebook Download
View all
Learn
View all