I have a WCF web service that is working fine. However there is one particular call that is failing - but only failing for certain users. The call is pretty simple - it is
I had this issue start happening when debugging from one web project to a web service in the same solution. The web service was returning responses that the web project couldnt understand. It would kind of work again at some points, then stop again.
It was because there was not an explicit reference between these projects, so the web service was not getting built when hitting F5 to start debugging. Once I added that, the errors went away.
I had this issue because my website did not have a certificate bound to the SSL port. I thought I'd mention it because I didn't find this answer anywhere in the googleweb and it took me hours to figure it out. Nothing showed up in the event viewer, which was totally awesome for diagnosing it. Hope this saves someone else the pain.
I found that you can get this error if the returned object has getter only auto properties that are initialized in the constructor (with C# 6.0 syntax).
I believe this is due to WCF deserializing objects on the client side using a parameter-less constructor then setting the properties on the object. It needs to have a set
available (it can be private) to fill the object, otherwise it'll fail.
After pulling my hair out for like 6 hours of this completely useless error, my problem ended up being that my data transfer objects
were too complex. Start with uber simple properties like public long Id { get; set;}
that's it... nothing fancy.
In my case it was also with serialization. I need to add
[KnownType(typeof(...)]
for all the classes that could appear in the serialization.