Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Binary deserialization to changed class
Message
From
07/07/2011 04:11:49
 
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 4.0
Miscellaneous
Thread ID:
01517444
Message ID:
01517532
Views:
41
>Hi,
>
>Can someone check me on this:
>
>I have a class that has been serialized to a data store using binary serialization.
>This : http://msdn.microsoft.com/en-us/library/ms229752.aspx implies that I should be able to deserialize this to a modified class.
>I added the following Property to the class:
[OptionalField]
>        private bool trackTweaks = true;
>        public bool TrackTweaks
>        {
>            get{return trackTweaks;}
>            set { trackTweaks = value; }
>        }
The BinarySerializer.Deserialize() now throws a "Method 'get_TrackTweaks' in type xxx from assembly yyy does not have an implementation." exception.
>My understanding is that the BinarySerializer only serializes fields. Why would it throw an error related to the TrackTweaks accessor?
>
>UPDATE: I think I was premature in my analysis. A quick check seems to indicate that I get the same exception even when deserializing from the updated class. Something more subtle must be happening......

UPDATE: Well duh!
I found that the control would serialize/deserialize fine in one project but not in another. Digging into the references on the failing project I discovered that someone had pointed to a DLL that only had the older version of the class so just changed it to reference the actual project and it works fine when deserializing both old and new versions of the class. That said I'm still not sure exactly why the BinarySerializer threw an exception.....
Previous
Reply
Map
View

Click here to load this message in the networking platform