Re: Serialization...
- From: "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 10 Apr 2007 10:47:33 -0400
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
.
- Follow-Ups:
- Re: Serialization...
- From: Atmapuri
- Re: Serialization...
- References:
- Serialization...
- From: Atmapuri
- Re: Serialization...
- From: Nicholas Paldino [.NET/C# MVP]
- Re: Serialization...
- From: Atmapuri
- Serialization...
- Prev by Date: New Row in the bound DataGridView
- Next by Date: Re: Permissions/Protection
- Previous by thread: Re: Serialization...
- Next by thread: Re: Serialization...
- Index(es):
Relevant Pages
|