Recently, we've been having a problem with our WCF service. This is how it's set up:
This is the readonly property:
Dictionary<string, string> _list;
[DataMember]
public IDictionary<string, string> Fields
{
get
{
if (_list == null)
_list = new Dictionary<string, string>();
return _list;
}
}
The client 'sets' this property easily by using the Fields.Add()
method.
Now recently we've been getting an exception that Fields should have a setter. I've read this on several other places, but this is the strange thing:
So why this sudden change? Could it be a different .NET Framework (the client may have updated overnight)? Are readonly properties really not supported in WCF, because it seems to work fine on other clients?
I never got any news about this anymore, and I'm no longer on that project, so here are some hints at solving this, if you encounter the same problem:
Clearly, in my case, the problem was down to one specific client. So the first two options are a possibility.