This project has moved. For the latest updates, please go here.

World Serializer with User Data

Topics: Developer Forum
Jan 10, 2013 at 11:31 PM

I got the World serializer working, but when trying to deserialize the User Data, it threw an "out of range" exception in the "ReadSimpleType" method.

The serialized type name was not 'assembly qualified', so the type deserialization was failing, causing the type to be null - in turn causing a extra call to "ReadSimpleType" method. My project is referencing Farseer in an external assembly so the full name was required for deserialization.

So in the Serializer.cs file, you can modify the WriteDynamicType method to use the assembly qualified name.

I know there could be an issue if the assembly information changes, but you could use a text editor to correct it.  Otherwise, I am open to other suggestions =]

        private void WriteDynamicType(Type type, object val)
            // JDB - Use AssemblyQualifiedName to enable deserialization of types in other assemblies
            //_writer.WriteElementString("Type", type.FullName);
            _writer.WriteElementString("Type", type.AssemblyQualifiedName);

            XmlSerializer serializer = new XmlSerializer(type);
            XmlSerializerNamespaces xmlnsEmpty = new XmlSerializerNamespaces();
            xmlnsEmpty.Add("", "");
            serializer.Serialize(_writer, val, xmlnsEmpty);
Jan 19, 2013 at 8:11 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.