Bugzilla – Bug 318295
[GMCS] binary serialization do not work with generics
Last modified: 2007-09-15 21:24:46 UTC
---- Reported by nazgul@omega.pl 2005-06-17 15:44:19 MST ---- Please fill in this template when reporting a bug, unless you know what you are doing. Description of Problem: Runtime fails to read deserialized field Steps to reproduce the problem: 1. Compile with gmcs t.cs using System; using System.IO; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; [Serializable] public class Tuple <a,b> { public a field1; public b field2; public Tuple (a x, b y) { field1 = x; field2 = y; } } public class Test { public static void Main() { //Creates a new TestSimpleObject object. TestSimpleObject obj = new TestSimpleObject(); Console.WriteLine("Before serialization the object contains: "); obj.Print(); //Opens a file and serializes the object into it in binary format. Stream stream = File.Open("data.xml", FileMode.Create); BinaryFormatter formatter = new BinaryFormatter(); //BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, obj); stream.Close(); //Empties obj. obj = null; //Opens file "data.xml" and deserializes the object from it. stream = File.Open("data.xml", FileMode.Open); formatter = new BinaryFormatter(); //formatter = new BinaryFormatter(); obj = (TestSimpleObject)formatter.Deserialize(stream); stream.Close(); Console.WriteLine(""); Console.WriteLine("After deserialization the object contains: "); obj.Print(); } } // A test object that needs to be serialized. [Serializable()] public class TestSimpleObject { public Tuple <string,int> member6; public TestSimpleObject() { member6 = new Tuple <string, int> ("aa", 22); } public void Print() { Console.WriteLine("member6 = '{0}'", member6); } } 2. Run mono t.exe 3. Actual Results: Before serialization the object contains: member6 = 'Tuple`2[[System.String, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' ** ERROR **: type 0x15 not handled in ves_icall_FieldInfo_SetValueInternal aborting... Aborted Expected Results: Before serialization the object contains: member6 = 'Tuple`2[System.String,System.Int32]' After deserialization the object contains: member6 = 'Tuple`2[System.String,System.Int32]' How often does this happen? Always Additional Information: ---- Additional Comments From miguel@ximian.com 2005-07-01 10:10:06 MST ---- The other location where this happens is in a similar method: mono_field_get_value_object. ---- Additional Comments From martin@ximian.com 2005-07-06 16:08:31 MST ---- Fixed in SVN. Unknown bug field "cf_op_sys_details" encountered while moving bug <cf_op_sys_details>mono svn from 17.06.2005</cf_op_sys_details> Unknown operating system unknown. Setting to default OS "Other".