Re: Serialization...

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



Hi!

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.

Or let the user make any customizations. But unfortunately not
supported by default. Consequently, the .NET community is now in a need
of an alternative commercial serialization system that allows saving/loading
application contents without restarting it :)

Thanks!
Atmapuri

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: Using multi-object graph with ISerializable interface
    ... Both the the parent and the children also inherit from the same base class. ... I do not understand how the name/value pairs can separate out the different classes when there is a collection and when they are all inheriting from the same base class. ... > As for the .net serialization, you may take a look at the links below. ... > to fully deserialize the object. ...
    (microsoft.public.dotnet.framework)
  • Re: How do you serialize object references?
    ... of multiple books with references to the same author. ... thus giving the serialization logic no ... but my reference books are not where I am right now so ... > the stream if there are also serializible. ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Challenge? [De-]Serialise a class derived from DataTable.
    ... as the deserialize method needs a type that is the same as the serialized ... so the deserialization will probably crash on the custom table ... ... however when i retrieve the values for serialization i can use this custom ... the custom datatables you would not have anny problem, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: version compatibility when serializing and deserializing
    ... As a side note you may want also to check http://msdn.microsoft.com/en-us/library/ms229752.aspx (Version Tolerant Serialization). ... Note thought that instead of analyzing the text word by word and even if you don't have any exception, it still could cause issues in the application if it is not prepared to deal with this. ... So keep just in mind that the basic issue is that you are either loosing some information or you add new information with default values as soon as you don't deserialize exactly what was serialized. ... "You might have version compatibility issues if you ever attemp to deserialize an object that has been serialized by an earlier version of your application, Specilically if you add a member to a custom class and attempt to deserialize an object that lacks that member, the runtime will throw an exeption. ...
    (microsoft.public.dotnet.languages.csharp)