protobuf-net v2 alpha - problems with Dictionary<string,string>?

Posted by Steve on Stack Overflow See other posts from Stack Overflow or by Steve
Published on 2010-06-16T22:53:23Z Indexed on 2010/06/17 22:33 UTC
Read the original article Hit count: 327

Filed under:

I was using a version of v2 of protobuf-net from a few weeks ago quite successfully. (I want to use V2 due to the speed of the pre-compiled serializer running on the Compact Framework.) Everything worked great until I tried to serialize an object with a property of type Dictionary. I received the following error:

{"No serializer defined for type: System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"}

It looked like there were recent changes made to improve Dictionary support, so I grabbed the latest code from today. After building the CF3.5 and FF3.5 dlls, I tried again. Now I get a different error "The model cannot be changed once frozen." If I remove the ProtoMember attribute from the Dictionary property all seems to work well.

Has anyone succcessfully used a Dictionary in v2 of protobuf-net? Is this still too early of a release to be using? My speed tests showed v2 being twice as fast, does that seem accurate (validating my desire to use the less stable v2 pre-alpha bits.)

© Stack Overflow or respective owner

Related posts about protobuf-net