open .net 2.0 serialized object with .net 1.1

D

Dennis C. Drumm

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
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 
D

Dennis C. Drumm

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 said:
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]
- (e-mail address removed)

Dennis C. Drumm said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top