469,950 Members | 2,341 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

Forcing re-serialization of a serialized object?

Hello,

The result of auto-converting some Java code to C# yielded
the following upgrade issue regarding the original Java
call to "reset()":

public virtual void writeObj(Object obj)
{
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(thisStream, obj);
Flush();

//UPGRADE_ISSUE:
Method 'java.io.ObjectOutputStream.reset' was not
converted. 'ms-
help://MS.VSCC.2003/commoner/redir/redirect.htm?
keyword="jlca1000_javaioObjectOutputStreamreset"'

reset();
}

At the bottom of this posting I have copied what the
Microsoft help on this issue provided. While I understand
what the problem is (that already serialized objects won't
be reserialized), I don't understand what they're saying
to do to correct the error. I looked at their two
solutions but didn't have a clue what the words meant. Is
there a simple way to force reserialization of the same
object?

Thanks,
Ray Mitchell
******FROM Microsoft's help link:

In Visual J++, this method sets the state of the
ObjectOutputStream object to the same state as when it was
created. As objects are serialized to the stream, the
ObjectOutputStream remembers which ones are already
serialized. If the program requests that already
serialized objects be written again, ObjectOutputStream
writes a reference to the previous object. Calling this
method causes ObjectOutputStream to serialize all
subsequent objects fully.

In the .NET Framework, there is no direct equivalent.

To correct this error

Use the
System.Runtime.Serialization.Formatters.BinaryForm atter.Bin
der property or the BinaryFormatter.Context property with
the source and destination of a serialized stream.
Nov 15 '05 #1
0 1130

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Hugh Lutley | last post: by
reply views Thread by Robert Wille | last post: by
1 post views Thread by Robert Wille | last post: by
12 posts views Thread by Howard Kaikow | last post: by
reply views Thread by steve | last post: by
4 posts views Thread by ATS16805 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.