[Mono-dev] ObservableCollection and BindingList Serialization
robertj at gmx.net
Tue Mar 12 09:47:30 UTC 2013
On 12.03.2013 00:16, Neale Ferguson wrote:
ObservableCollection was moved from Windows.Base to System and
> TypeForwardedTo and TypeForwardedFrom tags were added to the relevant source
> code. ObservableCollection is serializable but when done on a Windows system
> using .NET >= 3 the serialized object will still contain the WindowsBase,
> Version=126.96.36.199, Culture=Neutral, PublicKeyToken=31bf3856ad364e35 data but
> Mono will use System. Hence, if you serialize on Mono and then try and
> deserialize on .NET then you get an error message:
> Error when trying to deserialize with ObservableCollection: Unable to find
> assembly 'System'.
> Should the serializer use the forwarded information to ensure compatibility
> with older programs (and with what .NET does)?
MS.NET 4.0 beta was using the information gathered from
TypeForwardedFrom during serialization. Odds are that this
Then Mono's binary serialization machinery should be changed
to pay attention to this attribute during de/serialization,
maybe in class/corlib/System.Runtime.Serialization/ObjectManager.cs.
> In addition, Windows serializes a variable name _busyCount whereas Mono
> defines _count.
> Also, I note that BindingList serialization on Mono has different and
> missing variable names compared to the .NET equivalent. For example,
> allow_new is allowNew in .NET. In addition, do those serialized variables
> need to be public or should they be declared as private?
They must have the same visibility as in MS.NET.
Usually, when a class does not implement ISerializable, Mono's
implementation must be changed to match MS down to member naming.
It's a tedious work given that we don't look at MS' source code...
More information about the Mono-devel-list