Re: Serialization...

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



You are looking to overwrite an object that exists with serialization?
You can't do that. The easiest way for the serialization engine to
guarantee the validity of the data in the deserialized object would be to
handle the creation of the object.

For your solution, instead of passing the object around everywhere, you
should be getting the object from a well-known place, like a static property
on a class. Then, if you serialize/deserialize the member, you can just
discard what you were returning, and return your new instance.

Of course, this means that you have to patch up all of the calls on the
object reference that you have to reference the new well-known location, and
to not store references to the object.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Atmapuri" <dip@xxxxxxxxxxxxxxxx> wrote in message
news:OnT7PL3eHHA.1216@xxxxxxxxxxxxxxxxxxxxxxx
Hi!

When you deserialize an object, you aren't writing over an existing
object, you are creating a new object from information that was saved to
a
stream.

Also, when you serialize an object, the process doesn't destroy the
object. It just "reads" the object (and all references) and stores that
information in a stream. You can continue to use the object after you
have serialized it to a stream.

Hope this helps.

<g> Not really. The problem is that if I replace the object that I
deserialize, the rest of my application does not update the
pointers to it and continues to reference the old version.

Therefore, I hope that there is a way to deserialize an object in such a
way that it wont break the links.

For example, if you save the state of an application as a configuration
file using serialization, deserializing core objects in to new instances,
makes it very very difficult to update the links to those objects within
your app.

In extrem case you would have to specifiy at the command line, which
configuration file to use... instead of selecting from the menu, Load
settings..

Thanks!
Atmapuri





.



Relevant Pages

  • Re: Deserialize, CryptoStream, and NetworkStream
    ... the program works as expected and the server can deserialize the ... the zero byte signal from the stream is essential. ... > When you don't use a CryptoStream the Deserialize call can read the data ... the serialization protocol ought to be able to do exactly what ...
    (microsoft.public.dotnet.security)
  • Re: JSP Sessions,Attributes, and Deep Copy
    ... Java's standard serialization mechanism follows ... Second, session attributes. ... track a reference to the object in such a way that it can later ... set non-serializable objects as session attributes if you want your ...
    (comp.lang.java.programmer)
  • Re: Serialization...
    ... The easiest way for the serialization engine to ... object reference that you have to reference the new well-known location, ... information in a stream. ... deserialize, the rest of my application does not update the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Serialization Gurus? Unexpected Binary Behavior
    ... reference, you do not need usually to serialize both. ... restore it is necessary to backup some info will will allow to relink ... Now you have a totally separate but identical graph with an A' and B': ... binary serialization with an input of A'. ...
    (microsoft.public.dotnet.framework)
  • Re: mission based rl
    ... Factories for units, items, events, actions, handlers, effects. ... Ever look at the Boost serialization library? ... handling reference graphs, std containers and polymorphic references out ... used via a reference to a base class, specify the base class type with ...
    (rec.games.roguelike.development)