Re: Serialization woes

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Wild Wind (nobody_at_blackhole.com)
Date: 08/20/04


Date: Fri, 20 Aug 2004 12:20:24 +0100


"Wild Wind" <nobody@blackhole.com> wrote in message
news:2oijirFausd8U1@uni-berlin.de...
> Hello,
>
> I've been battling over this problem for
> the better part of a day, so I'd appreciate it
> if someone could shed some light here.
>
> I have a file which is produced by the custom binary
> serialization of an object (i.e. by implementing the
> ISerializable interface). This object has a hashtable
> as one of its members, and this hashtable is
> properly populated before the object that
> contains it is serialized to disk (again using
> custom serialization).
>
> I can confirm that when the file is created, it
> has information on the contents of the hashtable.
>
> However, when the object is deserialized, the
> hashtable now has all the data zapped from it.
>
> I've checked and rechecked that I am using the
> right names to put data in the SerializationInfo
> object in GetObjectData, and to extract the data
> in the special serialization constructor.
>
> I wish I could know what went on behind
> the scenes between the call to deserialize the
> object and the call to the special constructor.
> It's as if the SerializationInfo object is not
> being properly populated from the data in the
> file.

OK, it seems from googling around that the problem
is caused by the hashtable not being populated with
its elements *until* deserialization is complete -
at the time I am still deserializing it in the
special deserialization constructor, this hasn't
happened so there are no items in it.

It also turns out that the solution is for the class
that contains the hashtable and is being serialized/
deserialized to implement the IDeserializationCallback
interface and access the hashtable in the OnDeserialization
method of that call.

-- 
Akin
aknak at aksoto dot idps dot co dot uk


Relevant Pages

  • serialization inherited objects
    ... deserialization. ... Some extra propertys in the objects ... Now I would like some solution will the serialization keeps working. ... that in my app I would like to keep using my original name ...
    (microsoft.public.dotnet.languages.vb)
  • Re: cannot use static fields in AJAX applications?
    ... type's assembly is sufficient to resolve additional types. ... serializer construction for specific types. ... ViewState's built-in serialization does not like dynamically constructed ... serializers for later deserialization requests. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Serialization takes to long. Any suggestions?
    ... serialization is going to ... ArrayLists and HashTables. ... and DeSerialization works fine. ... perform this functionality from within SerializationInfo Constructor ...
    (microsoft.public.dotnet.framework)
  • Re: calling methods on deserialized objects
    ... serialization and deserialization breaks the internal connection between hashes and their associated classes, ... What "internal connection" are you refering to? ... The serialized structure looks good (I had a look at the session text file), references are replaced by their serialized target, no memory address pointers inside ... ... respective classes after deserialization, ...
    (comp.lang.perl.modules)
  • RE: ObjectManager Problem - Plea for help!
    ... RegisterObject() should be - as the documentation for RegisterObject says - ... The problem is that during deserialization I don't know that C2.m_s is the ... constructor required for custom serialization allows there to be a level of ... the formatter code would need to change to: ...
    (microsoft.public.dotnet.framework)