[Mono-dev] Problem with BinarySerialization
Robert Jordan
robertj at gmx.net
Tue Feb 2 08:15:52 EST 2010
On 02.02.2010 14:01, PFJ wrote:
>
> Hi,
>
>
> Robert Jordan wrote:
>>
>> The serialization infrastructure heavily relies on type/assembly
>> identity, but what you're doing here is trying to create an object
>> from serialization data generated from a totally different class.
>>
>> You should implement "Elements" in a separated assembly which you
>> reference from both apps. Then, in you "Form", you should aggregate
>> Elements, i.e. make it a field, because de/serializing a Form
>> is not what you want. Really.
>>
>
> Ah....
>
> What I have done is created a completely different app to generate the
> serialized data - it's intended to be run once, create the data file and
> that's it.
>
> The file is then sucked in to the 2nd application for deserializing. Would
> what I want to do be better using an Xml serialized file or will I hit the
> same problem? Failing that I'm guessing I'll need to draw the file into a
> list (more or less the reverse of creating the list in the first place).
You won't hit the same problem but you'd still have to duplicate
Elements code.
Thus, the only *clean* way to solve this is introducing a shared
assembly implementing the classes you want to serialize. It's a
common pattern.
Robert
More information about the Mono-devel-list
mailing list