PC Review


Reply
Thread Tools Rate Thread

BinaryFormatter Version mismatch

 
 
=?Utf-8?B?cGFrMjAxMTY=?=
Guest
Posts: n/a
 
      24th May 2005
Hi, all:

I've seen numerous questions and answers about this topic on the web, but
none of them quite fit to my case. My application is a business process
model (like approval process) using ASP.NET. Each transaction, I store
related data in the database as a blob. When I retreive the data from
database, deserialization fails and I get this error:
"BinaryFormatter Version incompatibility. Expected Version 1.0. Received
Version 49.0."
Looks like there is an ASCII and binary problem (ASCII value 1 is 49), but I
can't get around this. Can I somehow set the BinaryFormatter not to check the
version information? Can I make it to skip this version check?

Any help will be appreciated.

Thanks

Sung.
 
Reply With Quote
 
 
 
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      24th May 2005
pak20116 <(E-Mail Removed)> wrote:
> I've seen numerous questions and answers about this topic on the web, but
> none of them quite fit to my case. My application is a business process
> model (like approval process) using ASP.NET. Each transaction, I store
> related data in the database as a blob. When I retreive the data from
> database, deserialization fails and I get this error:
> "BinaryFormatter Version incompatibility. Expected Version 1.0. Received
> Version 49.0."
> Looks like there is an ASCII and binary problem (ASCII value 1 is 49), but I
> can't get around this. Can I somehow set the BinaryFormatter not to check the
> version information? Can I make it to skip this version check?


If the version information is garbled, I see no reason to believe the
rest of your data would be okay.

I would split the problem into two halves:

1) Make sure you can serialize to a byte array and then deserialize
again.

2) Make sure you can store a byte array in your database and retrieve
it again.

Once you've worked out which of these stages is the problem, it'll be a
lot easier to fix.

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
=?Utf-8?B?cGFrMjAxMTY=?=
Guest
Posts: n/a
 
      24th May 2005
Hi,
Thank you for your quick response.
I apologize for mulitple posts. I'll be more careful from now on.
I tried those two and both work fine. The problem I'm facing is that I
serialized and entered data few weeks ago and I'm trying to retreive them.
If I make data entry now, it works fine. Do you think maybe data in the
database is corrupted?

Thanks.

"Jon Skeet [C# MVP]" wrote:

> pak20116 <(E-Mail Removed)> wrote:
> > I've seen numerous questions and answers about this topic on the web, but
> > none of them quite fit to my case. My application is a business process
> > model (like approval process) using ASP.NET. Each transaction, I store
> > related data in the database as a blob. When I retreive the data from
> > database, deserialization fails and I get this error:
> > "BinaryFormatter Version incompatibility. Expected Version 1.0. Received
> > Version 49.0."
> > Looks like there is an ASCII and binary problem (ASCII value 1 is 49), but I
> > can't get around this. Can I somehow set the BinaryFormatter not to check the
> > version information? Can I make it to skip this version check?

>
> If the version information is garbled, I see no reason to believe the
> rest of your data would be okay.
>
> I would split the problem into two halves:
>
> 1) Make sure you can serialize to a byte array and then deserialize
> again.
>
> 2) Make sure you can store a byte array in your database and retrieve
> it again.
>
> Once you've worked out which of these stages is the problem, it'll be a
> lot easier to fix.
>
> --
> Jon Skeet - <(E-Mail Removed)>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too
>

 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      24th May 2005
pak20116 <(E-Mail Removed)> wrote:
> Thank you for your quick response.
> I apologize for mulitple posts. I'll be more careful from now on.
> I tried those two and both work fine. The problem I'm facing is that I
> serialized and entered data few weeks ago and I'm trying to retreive them.
> If I make data entry now, it works fine. Do you think maybe data in the
> database is corrupted?


Either that, or you've changed the contents of your class since you
saved the data into the database.

I don't know how versioning works with BinaryFormatter, but if you've
changed your class (e.g. added a field) then I think you'll have to add
support in to deserialize "old" versions.

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
=?Utf-8?B?U3RldmUgVGVlcGxlcw==?=
Guest
Posts: n/a
 
      24th May 2005
How would you go about adding support for deserializing older versions of the
saved data? This is the exact problem I am having. I saved data several
days ago and added a field to my class. Now when deserializing I get an
exception error. Do you have an example of how this solution can be
implemented? Help would be greatly appreciated as resolving this issue is
critical to my application.
--
Steve


"Jon Skeet [C# MVP]" wrote:

> pak20116 <(E-Mail Removed)> wrote:
> > Thank you for your quick response.
> > I apologize for mulitple posts. I'll be more careful from now on.
> > I tried those two and both work fine. The problem I'm facing is that I
> > serialized and entered data few weeks ago and I'm trying to retreive them.
> > If I make data entry now, it works fine. Do you think maybe data in the
> > database is corrupted?

>
> Either that, or you've changed the contents of your class since you
> saved the data into the database.
>
> I don't know how versioning works with BinaryFormatter, but if you've
> changed your class (e.g. added a field) then I think you'll have to add
> support in to deserialize "old" versions.
>
> --
> Jon Skeet - <(E-Mail Removed)>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too
>

 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      24th May 2005
Steve Teeples <(E-Mail Removed)> wrote:
> How would you go about adding support for deserializing older versions of the
> saved data? This is the exact problem I am having. I saved data several
> days ago and added a field to my class. Now when deserializing I get an
> exception error. Do you have an example of how this solution can be
> implemented? Help would be greatly appreciated as resolving this issue is
> critical to my application.


Unfortunately I don't know much about binary formatting - I suspect
that without having already put in support in the old code for
specifically serializing in a known format, you may well be stuck.

When you say it's critical to your application, do you mean the ability
to add to your class and still be able to deserialize is critical, or
just to extract this data? If it's the latter, I'd suggest going back
to an older version of the class, deserialising and saving the data in
another (more explicit) way, then putting the fields back in, loading
the data again and reserializing.

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
=?Utf-8?B?U3RldmUgVGVlcGxlcw==?=
Guest
Posts: n/a
 
      25th May 2005
I'm creating a test tool that over time may require tweaks to the class
components which contain the test requirement data that is serialized to
disk. I want to be able to update these classes over time as necessary but
still read data from older versions of the "serialized" data. Is there
another solution maybe?
--
Steve


"Jon Skeet [C# MVP]" wrote:

> Steve Teeples <(E-Mail Removed)> wrote:
> > How would you go about adding support for deserializing older versions of the
> > saved data? This is the exact problem I am having. I saved data several
> > days ago and added a field to my class. Now when deserializing I get an
> > exception error. Do you have an example of how this solution can be
> > implemented? Help would be greatly appreciated as resolving this issue is
> > critical to my application.

>
> Unfortunately I don't know much about binary formatting - I suspect
> that without having already put in support in the old code for
> specifically serializing in a known format, you may well be stuck.
>
> When you say it's critical to your application, do you mean the ability
> to add to your class and still be able to deserialize is critical, or
> just to extract this data? If it's the latter, I'd suggest going back
> to an older version of the class, deserialising and saving the data in
> another (more explicit) way, then putting the fields back in, loading
> the data again and reserializing.
>
> --
> Jon Skeet - <(E-Mail Removed)>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too
>

 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      25th May 2005
Steve Teeples <(E-Mail Removed)> wrote:
> I'm creating a test tool that over time may require tweaks to the class
> components which contain the test requirement data that is serialized to
> disk. I want to be able to update these classes over time as necessary but
> still read data from older versions of the "serialized" data. Is there
> another solution maybe?


Well, you could implement ISerializable and have a constructor
accepting SerializationInfo and StreamingContext, as documented in
ISerializable, but unless you particularly require the automatic
serialization or your class has a lot of complex fields, I'd be tempted
to write methods which loaded and saved in a custom format yourself.

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
=?Utf-8?B?U3RldmUgVGVlcGxlcw==?=
Guest
Posts: n/a
 
      25th May 2005
I think it would be easiest to use a custom method given the limitations of
serialization and versioning. Thanks for the time and suggestions.
--
Steve


"Jon Skeet [C# MVP]" wrote:

> Steve Teeples <(E-Mail Removed)> wrote:
> > I'm creating a test tool that over time may require tweaks to the class
> > components which contain the test requirement data that is serialized to
> > disk. I want to be able to update these classes over time as necessary but
> > still read data from older versions of the "serialized" data. Is there
> > another solution maybe?

>
> Well, you could implement ISerializable and have a constructor
> accepting SerializationInfo and StreamingContext, as documented in
> ISerializable, but unless you particularly require the automatic
> serialization or your class has a lot of complex fields, I'd be tempted
> to write methods which loaded and saved in a custom format yourself.
>
> --
> Jon Skeet - <(E-Mail Removed)>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BinaryFormatter Version incompatibility. =?Utf-8?B?cmxyY3N0cg==?= Microsoft C# .NET 4 20th Sep 2006 09:30 PM
CRT version mismatch =?Utf-8?B?d2FuemVsYmlu?= Microsoft Dot NET Framework 1 6th Jul 2006 09:34 AM
BinaryFormatter version mismatch =?Utf-8?B?cGFrMjAxMTY=?= Microsoft C# .NET 1 24th May 2005 05:43 PM
BinaryFormatter Version incompatibility. Expected Version 1.0. Received Version 1986938170.1886350437 Joshua Moore Microsoft C# .NET 3 28th May 2004 03:45 AM
Serialization and BinaryFormatter version incompatibility exceptions Doug Lind Microsoft VB .NET 2 16th Sep 2003 08:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:23 PM.