Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Binary deserialization to changed class
Message
De
07/07/2011 04:11:49
 
 
À
06/07/2011 12:04:21
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 4.0
Divers
Thread ID:
01517444
Message ID:
01517532
Vues:
42
>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.....
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform