I have a complex object hierarchy that I’ve been wrestling with to get passed across the wire in its entirety when using Silverlight with WCF. I’ve tried DataContractSerializer to death and the main problem is that I’m trying to use Dictionary, with multiple cyclical references and just couldn’t get it to work.
I’ve switched to look at protobuf-net thinking that it might be better all round to use a binary format anyway. I was hoping to be able to just do a lot of find and replace to add the ProtoMember attributes on to the properties. However a lot of the properties that were being serialized with DataMember attributes are declared as Friend (vb.net). I’ve found that protobuf-net throws an error when deserializing, saying
Attempt by method <blah> to access field <fieldname> failed.
I’ve found that setting the field to protected causes the same error, and the only way around it is to set the field to public – which is something I don’t want to do. Is it possible to do this with a protected setter or similar on the property the field backs? While this would be a pain (many fields/properties and classes) it would at least solve the problem. The serialization on the back end works fine.
If this is not possible, can anyone suggest how I can get a complex object hierarchy with cyclical references that include multiple dictionaries across the wire in their complete form? I realise Silverlight adds a few constraints to this process, but hopefully someone has already succeeded with this.
Note this is Silverlight 5
In Silverlight: no; the runtime has a higher level of paranoia, and you just can’t get at the non-public parts of other types. Even the Silverlight
DataContractSerializerpage has the caveat:My understanding is that this can’t be avoided on Silverlight.