I created a WCF service.in my data contract I have two attributes lets say:
[DataMember]
Private User objUser;
and
[DataMember]
Private tempClass ObjTemp;
I have get and set property for both the attributes. In my implementation class, I have an object of datacontract class... lets say. objData
.
When I assign
objData.ObjTemp=(function which return objTemp);
the service work fine. But, when I assign.
objData.objUser=(function which return objUser)
it throws following error:
The underlying connection was closed: The connection was closed unexpectedly.
When I comment
objData.objUser=(function which return objUser)
it works fine again.
When I inspect the code inside my User class, I found one property creating problem. When I change the property that property it works fine too; but i do not know why that property is creating problem.
The property is like this:
public IPAddress IP { get; set; }
Now this IPAdress class contains a constructor, and get and set for ip variable. In the get, it simply returns ip variable.
in set it checks some condition and then assign value to ip variable. If condition fails, it throws an exception. Can anybody explain what the problem could be?
I just checked another thing.
If i remove [DataMember]
attribute from private User objUser;
it works fine; but if i put [DataMember]
back it generates the same error.
any suggestions?