471,570 Members | 1,305 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,570 software developers and data experts.

open .net 2.0 serialized object with .net 1.1

Is there a way to open files with .net 1.1 versions of my software product
that were serialized with a .net 2.0 version of same product? Right now, as
soon as my older .net 1.1 application tries to read the stream, an exception
is thrown. The code to read the stream looks like this:

BinaryFormatter bf = new BinaryFormatter();
bf.AssemblyFormat = FormatterAssemblyStyle.Simple;
IFormatter formatter = bf;
FileStream stream = new FileStream(this.fileName, FileMode.Open,
FileAccess.Read, FileShare.Read);
object list = formatter.Deserialize(stream);
stream.Close();

the objects being serialized all have the [Serializable] attribute and are
serialized with ISerializable.GetObjectData and deserialized with the
special object constructor with the SerializationInfo and StreamingContext
parameters.

Thanks,

Dennis
Nov 26 '05 #1
2 1844
Dennis,

What exception is being thrown? What are the details?

If you are running the same code, and the serialized type is the same
(meaning, you didn't re-compile it), then it ^should^ work. However, if you
re-compiled the type, then the type signature is most likely different, and
you will more than likely have problems de-serializing it.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dennis C. Drumm" <dc******@community.nospam> wrote in message
news:O6**************@tk2msftngp13.phx.gbl...
Is there a way to open files with .net 1.1 versions of my software product
that were serialized with a .net 2.0 version of same product? Right now,
as soon as my older .net 1.1 application tries to read the stream, an
exception is thrown. The code to read the stream looks like this:

BinaryFormatter bf = new BinaryFormatter();
bf.AssemblyFormat = FormatterAssemblyStyle.Simple;
IFormatter formatter = bf;
FileStream stream = new FileStream(this.fileName, FileMode.Open,
FileAccess.Read, FileShare.Read);
object list = formatter.Deserialize(stream);
stream.Close();

the objects being serialized all have the [Serializable] attribute and are
serialized with ISerializable.GetObjectData and deserialized with the
special object constructor with the SerializationInfo and StreamingContext
parameters.

Thanks,

Dennis

Nov 28 '05 #2
Thanks Nicholas,

I did re-comple it.

Is the change in the type signature something to do with going from .net
framework 1.1 to 2.0 only? I ask becuase I have many version of the
application using .net framework 1.1 and they all can deserialize the files
without problems.

Also, can you point me to some documentation on this situation, something
that explains why the type signature is being changed and what exactly that
implies?

Thanks,

Dennis
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Oj**************@TK2MSFTNGP15.phx.gbl...
Dennis,

What exception is being thrown? What are the details?

If you are running the same code, and the serialized type is the same
(meaning, you didn't re-compile it), then it ^should^ work. However, if
you re-compiled the type, then the type signature is most likely
different, and you will more than likely have problems de-serializing it.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dennis C. Drumm" <dc******@community.nospam> wrote in message
news:O6**************@tk2msftngp13.phx.gbl...
Is there a way to open files with .net 1.1 versions of my software
product that were serialized with a .net 2.0 version of same product?
Right now, as soon as my older .net 1.1 application tries to read the
stream, an exception is thrown. The code to read the stream looks like
this:

BinaryFormatter bf = new BinaryFormatter();
bf.AssemblyFormat = FormatterAssemblyStyle.Simple;
IFormatter formatter = bf;
FileStream stream = new FileStream(this.fileName, FileMode.Open,
FileAccess.Read, FileShare.Read);
object list = formatter.Deserialize(stream);
stream.Close();

the objects being serialized all have the [Serializable] attribute and
are serialized with ISerializable.GetObjectData and deserialized with the
special object constructor with the SerializationInfo and
StreamingContext parameters.

Thanks,

Dennis


Nov 29 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.