[Mono-bugs] [Bug 54614][Wis] New - Compatiblity problems between platforms with BinaryFormatter
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Thu, 19 Feb 2004 15:05:50 -0500 (EST)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by gileslforster@yahoo.co.uk.
http://bugzilla.ximian.com/show_bug.cgi?id=54614
--- shadow/54614 2004-02-19 15:05:50.000000000 -0500
+++ shadow/54614.tmp.7722 2004-02-19 15:05:50.000000000 -0500
@@ -0,0 +1,195 @@
+Bug#: 54614
+Product: Mono/Runtime
+Version: unspecified
+OS: Mandrake 9.2
+OS Details: XP and Mandrake 9.2
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: gileslforster@yahoo.co.uk
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Compatiblity problems between platforms with BinaryFormatter
+
+Description of Problem:
+
+Using Mono 0.30 and .NET 1.1 on Windows, Serialisation of some simple
+objects produce incompatable results.
+
+On Windows, serialization of the objects bellow, and desrialization
+works.
+
+On Mono, Serialization of the objects below, and deserialization work.
+
+Serialization on Windows and Deserialization on Mono works
+
+Serialization on Mono and Deserialization on Mono DOES NOT.
+
+To summarise.
+
+Windows to Windows - Ok
+Mono to Mono - Ok
+Windows to Mono - Ok
+Mono to Windows - Fails
+
+
+Steps to reproduce the problem:
+1. Using the folling classes
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Runtime.Serialization;
+using System.Runtime.Serialization.Formatters;
+using System.Runtime.Serialization.Formatters.Binary;
+
+[Serializable()]
+ public class SimpleObject : IDeserializationCallback
+ {
+ private string name;
+ private int id;
+
+ [NonSerialized()]
+ public static int Count;
+
+ public string Name
+ {
+ get { return name; }
+ set { name = value; }
+ }
+
+ public int ID
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ static SimpleObject()
+ {
+ Count = 0;
+ }
+
+ public SimpleObject()
+ {
+ name = "bob";
+ id = 10;
+ Count++;
+ }
+
+ public SimpleObject(string name, int id)
+ {
+ this.name = "bob";
+ this.id = 10;
+ Count++;
+ }
+
+ ~SimpleObject()
+ {
+ Count--;
+ }
+
+ void IDeserializationCallback.OnDeserialization(Object
+sender)
+ {
+ Count++;
+ }
+ }
+
+ [Serializable()]
+ public class NotSoSimpleObject : SimpleObject
+ {
+ private string thingy;
+
+ public NotSoSimpleObject()
+ {
+ thingy = "Hello";
+ }
+
+ public NotSoSimpleObject(string name, int id)
+ : base(name, id)
+ {
+ thingy = "Hello";
+ }
+ }
+
+ /// <summary>
+ /// Summary description for Class1.
+ /// </summary>
+ class Class1
+ {
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ [STAThread]
+ static void Main(string[] args)
+ {
+ int i;
+ BinaryFormatter bf = new BinaryFormatter();
+ SimpleObject simple = null;
+
+ //========================
+ // Serialisation Test
+ //========================
+
+ ArrayList vec = new ArrayList();
+
+ simple = new NotSoSimpleObject("Testing Object",
+1);
+
+ Stream sw = File.Create("SimpleObjects.bin");
+
+ bf.Serialize(sw, simple);
+ sw.Close();
+
+ Console.WriteLine("Created Simple object.");
+
+ //========================
+ // Deserialization Test
+ //========================
+ Stream sr = File.OpenRead("SimpleObjects.bin");
+ simple = (SimpleObject)bf.Deserialize(sr);
+
+ Console.WriteLine("Loaded Simple Object");
+
+ sr.Close();
+ }
+ }
+
+
+2.
+
+In the main function, comment out the Serialize and Deserialize
+respectively on Mono and Windows to test, serialising in and out of the
+different systems. The both create a file called simple.bin
+3.
+
+Actual Results:
+
+Fails loading on .NET 1.1 when writing from Mono
+
+Expected Results:
+
+Should work.
+
+How often does this happen?
+
+Always, never mind what happens when you try to use something like an
+ArrayList, as all the Systrem defined objects seem completely
+incompatible.
+
+Additional Information:
+
+Looking at what is produced in each, Mono seems to not add the full
+qualifiers of member fields to the object it belongs to. e.g Mono
+writes "name" instead of "SimpleObject+Name" - could this be causing the
+problem.
+
+Anyway, I suspect many people are using serialization to save and load
+data easily, and they are going to find this a real problem in the
+future, if they can't even read and write their own types in a consistent
+manner, never mind as I said things like the ArrayList.