This is a short post on something that caught me out, primarily due to the awful client side error message.
The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.
I was implementing a WCF service to allow my client to get historic data from the service. But as the History object might become large I also wanted a HistorySummary object with the bare minimum data. So for example my client UI would list the history summary data and only when the user clicked on the summary would the full data get loaded.
So I implemented my HistorySummary (abridged version below)
[DataContract] public class HistorySummary { [DataMember] public string Name { get; set; } // ... other properties }
From this I derived my History object (also abridged)
[DataContract] public class History : HistorySummary { [DataMember] public string[] Reports { get; set; } // ... other properties }
If you’re experienced in WCF you’ll immediately spot the problem straight away.
I built the server and ran it, no problems. I regenerated the proxies and ran the client and bang ! I get the less than helpful error message shown above.
KnownTypes was the problem. Easy to forget. The base class, HistorySummary should have looked like this
[DataContract] [KnownType(typeof(History))] public class HistorySummary { [DataMember] public string Name { get; set; } // ... other properties }