I know, I’ve red that Unity has a problem when deserializing Dictionary Generic so we can no use them.
But this is not entire true, unity has a problem but only when serialized versions comes from 2 different builds version (you know Unity change the assembly in every build).
I say this, because If you use the same build you can successfully serialize and deserialize custom classes with generic dictionaries with custom class as values!! 100% reproducible, no problems at all.
This without any problem, until you change the build.
So due unity assemble name change, that brings problem to BinaryFormmater, I use the SerializerBinder that is all around the forum to resolve this issue.
Is that, using the Binder (because it is another version) that unity can not load types for generic Dictionaries.
And I wonder: what in the world has to do this either if the version was take by the binder or not that the deserializer dictionaries generic work or not?
Shouldn’t work in all cases?
If the binder is bringing the problem?, what is it?, why unity after using the binder for binnary formatter can not deserialize dictionaries but if not it can?
Is there a quick fix?
Thanks.
the build related serializion issue is a binaryformatter thing, there is a thread with an approach thats said to work. (you need to make the formatter independent of the binary)
but when it comes to serializing generic dictionary in U2 / iphone 1.x, its a .net thing. SerializableDictionary<,> which you can find on the web overcomes this problem.
Thanks for the answer, I suppose you mean to compiled in external dll? I using webplayer, will it bring any problem? Because using the SerilizerBinder as the forum says resolved the problem but bring the dictionary issue.
But I quite don’t understand if it is a .net thing, why the 3.0 unity say in the log that it fix the deserilization problem for dictionaries and lists?
Besides, why I can deserizlie and serilize (no mater how many times is 100% reproducible) without any problem using the same version but if using the Binder + Other version, it dictionary deserilization problem comes?
Thank in advance
No, nothing was in relation to an external dll, all in unity.
Can’t comment on the changelog entry
The serialization is a binary formatter thing. I’m sure on that cause the XMLSerializer works without any problem
Ah, ok, I understand that ALSO binaryformmater has bug from more that 5 year ago that MS hasn’t fixed.
But then what do you mean by “formmated independent from binary”, sorry if it clear, but I quite don’t understand it.
The options I have to resolve the version issue is the versionBinder (ok), or compile the savedata section in a extarnal dll (not like to do)
But shouln’t anyway I be not able to serialize and deserilize generic dictionaries (independent of version etc),
By the way, you mean Paul Welters SerializableDictionray right?
Thanks.
I hope you know that unity at no point in time touches the MS .NET framework at all.
Its mono from start to end.
With “independent from build” I meant the SerilizerBinder path, which seems to work from your wording. I’ve never tested it after a workable serialization was in place that not only allowed the serialization for this purpose but also serialization of external input independent of unity and .net
and no, the regular dictionary<,> in .net 2 does not support serialization at all, mono 1.2.5 as used in Unity 2.x / Unity iPhone 1.x suffers from it too, thats where the SerializableDictionary solves the problem (Paul Welters, right)