Deserialization of changed objects

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Urs Vogel

    Deserialization of changed objects

    Hi

    Let's assume that I have an object_V1 (version 1) serialized to disk. Later,
    the class for object_V1 will change to object_V2, having some more members.
    Now, I would like to read my previously saved objects of type object_V1 into
    object_V2, which (logically) now throws an exception.

    I tried to make use of the HeaderHandler, but this gives me only access to
    the methods, not the members. I also tried to inherit object_V1 into
    object_V2, which didn't work either.

    Is there an way to control this deserialization process, any samples around?

    Any hints ar appreciated.

    Thanks. Urs.


  • Joe Mayo

    #2
    Re: Deserialization of changed objects



    "Urs Vogel" <ursvogel@yahoo .com> wrote in message
    news:Oqqp28PsDH A.2456@TK2MSFTN GP12.phx.gbl...[color=blue]
    >
    > Is there an way to control this deserialization process, any samples[/color]
    around?[color=blue]
    >[/color]

    Hi Urs,

    You'll need to implement ISerializable on the type you are serializing and
    deserializing and control the versioning yourself.

    Joe
    --
    Welcome to C# Station!  This is a community site for people interested in applying .NET using the C# programming language.  We’ve been around since July 4th 2000 and have continued to grow over the years.  Items of interest include Articles, Books, Links, Documentation,  and Tutorials. More… Source Code If you would like to see an […]



    Comment

    • rsarosh@hotmail.com

      #3
      Deserialization of changed objects

      you can deserialize the same object, if you changed the
      object by adding a property, i am afraid you are going to
      get a fresh and warm exception ... Lets wait and see if
      some one tells otherwise ..

      - Sarosh
      [color=blue]
      >-----Original Message-----
      >Hi
      >
      >Let's assume that I have an object_V1 (version 1)[/color]
      serialized to disk. Later,[color=blue]
      >the class for object_V1 will change to object_V2, having[/color]
      some more members.[color=blue]
      >Now, I would like to read my previously saved objects of[/color]
      type object_V1 into[color=blue]
      >object_V2, which (logically) now throws an exception.
      >
      >I tried to make use of the HeaderHandler, but this gives[/color]
      me only access to[color=blue]
      >the methods, not the members. I also tried to inherit[/color]
      object_V1 into[color=blue]
      >object_V2, which didn't work either.
      >
      >Is there an way to control this deserialization process,[/color]
      any samples around?[color=blue]
      >
      >Any hints ar appreciated.
      >
      >Thanks. Urs.
      >
      >
      >.
      >[/color]

      Comment

      Working...