[Mono-devel-list] Regression in Soap serialization
Lluis Sanchez
lluis at ximian.com
Mon Aug 1 07:46:34 EDT 2005
I forgot to commit one change in corlib. It should be fixed now.
Thanks!
Lluis.
El dl 01 de 08 del 2005 a les 13:18 +0200, en/na Kamil Skalski va
escriure:
> This patch http://lists.ximian.com/pipermail/mono-patches/2005-July/061773.html
> caused regression in serialization example from
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnonserializedattributeclasstopic.asp
>
> using System;
> using System.IO;
> using System.Runtime.Serialization;
> using System.Runtime.Serialization.Formatters.Soap;
> //using System.Runtime.Serialization.Formatters.Binary;
>
> 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);
> SoapFormatter formatter = new SoapFormatter();
>
> //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 SoapFormatter();
>
> //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 int member1;
> public string member2;
> public string member3;
> public double member4;
>
> // A field that is not serialized.
> [NonSerialized()] public string member5;
>
> public TestSimpleObject() {
>
> member1 = 11;
> member2 = "hello";
> member3 = "hello";
> member4 = 3.14159265;
> member5 = "hello world!";
> }
>
>
> public void Print() {
>
> Console.WriteLine("member1 = '{0}'", member1);
> Console.WriteLine("member2 = '{0}'", member2);
> Console.WriteLine("member3 = '{0}'", member3);
> Console.WriteLine("member4 = '{0}'", member4);
> Console.WriteLine("member5 = '{0}'", member5);
> }
> }
>
>
> gives exception
>
> Unhandled Exception: System.TypeInitializationException: An exception
> was thrown by the type initializer for
> System.Runtime.Serialization.Formatters.Soap.SoapTypeMapper --->
> System.ArgumentException: Key duplication when adding:
> nonPositiveInteger http://www.w3.org/2001/XMLSchema
> in <0x001d0> System.Collections.Hashtable:PutImpl (System.Object key,
> System.Object value, Boolean overwrite)
> in <0x00012> System.Collections.Hashtable:Add (System.Object key,
> System.Object value)
> in <0x00064> System.Runtime.Serialization.Formatters.Soap.SoapTypeMapper:RegisterType
> (System.Type type, System.String name, System.String namspace, Boolean
> reverseMap)
> in <0x00060> System.Runtime.Serialization.Formatters.Soap.SoapTypeMapper:RegisterType
> (System.Type type)
> in <0x002e9> System.Runtime.Serialization.Formatters.Soap.SoapTypeMapper:InitMappingTables
> ()
> in <0x0011b> System.Runtime.Serialization.Formatters.Soap.SoapTypeMapper:.cctor
> ()--- End of inner exception stack trace ---
>
> in <0x00000> <unknown method>
> in <0x000c5> System.Runtime.Serialization.Formatters.Soap.SoapFormatter:Serialize
> (System.IO.Stream serializationStream, System.Objectgraph,
> System.Runtime.Remoting.Messaging.Header[] headers)
> in <0x00015> System.Runtime.Serialization.Formatters.Soap.SoapFormatter:Serialize
> (System.IO.Stream serializationStream, System.Objectgraph)
> in <0x00071> Test:Main ()
>
More information about the Mono-devel-list
mailing list