[Mono-bugs] [Bug 349053] unable to serialize SortedDictionary

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Aug 28 12:40:01 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=349053

User aaragoneses at novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=349053#c5





--- Comment #5 from Andrés G. Aragoneses <aaragoneses at novell.com>  2008-08-28 10:40:00 MDT ---
Ooops, no, even with SoapFormatter you cannot serialize an IDictionary object,
but now I see that the testcase is using BinaryFormatter. Just for the sake of
simplicity, the code is this:

SortedDictionary<string, int> test = new SortedDictionary<string, int>();

test.Add("dfds", 2323);

FileStream fs = new FileStream("Cache.bin", FileMode.Create, FileAccess.Write,
FileShare.Read);

System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

bf.Serialize(fs, test);

fs.Close();


And the error is:


Unhandled Exception: System.Runtime.Serialization.SerializationException: Type
System.Collections.Generic.RBTree is not marked as Serializable.
  at
System.Runtime.Serialization.Formatters.Binary.BinaryCommon.CheckSerializable
(System.Type type, ISurrogateSelector selector, StreamingContext context)
[0x0002c] in
/usr/src/packages/BUILD/mono-1.9.1/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/BinaryCommon.cs:118 
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.GetObjectData
(System.Object obj,
System.Runtime.Serialization.Formatters.Binary.TypeMetadata& metadata,
System.Object& data) [0x00054] in
/usr/src/packages/BUILD/mono-1.9.1/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:386 
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObject
(System.IO.BinaryWriter writer, Int64 id, System.Object obj) [0x00000] in
/usr/src/packages/BUILD/mono-1.9.1/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:306 
  at
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObjectInstance
(System.IO.BinaryWriter writer, System.Object obj, Boolean isValueObject)
[0x00062] in
/usr/src/packages/BUILD/mono-1.9.1/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:293 
  at
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteQueuedObjects
(System.IO.BinaryWriter writer) [0x00005] in
/usr/src/packages/BUILD/mono-1.9.1/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:271 
  at
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObjectGraph
(System.IO.BinaryWriter writer, System.Object obj,
System.Runtime.Remoting.Messaging.Header[] headers) [0x0001f] in
/usr/src/packages/BUILD/mono-1.9.1/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:256 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize
(System.IO.Stream serializationStream, System.Object graph,
System.Runtime.Remoting.Messaging.Header[] headers) [0x000a4] in
/usr/src/packages/BUILD/mono-1.9.1/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs:230 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize
(System.IO.Stream serializationStream, System.Object graph) [0x00000] in
/usr/src/packages/BUILD/mono-1.9.1/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs:209 
  at Test.MainClass.Main (System.String[] args) [0x0002a] in
/home/knocte/Projects/Test/Test/Main.cs:39 


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list