Ok, for now I’ll use the class library technique.
I have found what seems to be a difference between Xna and Monogame. It is about deserializing multidimentionnal arrays. Maybe i’m missing something.
I got a simple class I want to serialize with a byte[][] array.
public class Mask
{
public byte[][] array;
}
Under Xna, I serialized it as:
<?xml version="1.0" encoding="utf-8"?>
<XnaContent>
<Asset Type="Workshop01.Custom.Mask">
<array>
<Item>1 1 1</Item>
<Item>1 1 1</Item>
</array>
</Asset>
</XnaContent>
And it was OK. But the monogame content pipeline does not accept it and gives me this error:
D:/[...]/workshop01/Workshop01/Content/Data/mask.xml: error: Importer 'XmlImporter' had unexpected failure!
Microsoft.Xna.Framework.Content.Pipeline.InvalidContentException: An error occured parsing. ---> System.Xml.XmlException: 'Element' est un XmlNodeType non valide. Ligne 6, position 8.
… System.Xml.XmlReader.ReadEndElement()
… Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateReader.ReadRawObject[T](ContentSerializerAttribute format, ContentTypeSerializer typeSerializer, T existingInstance)
… Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateReader.ReadObject[T](ContentSerializerAttribute format, ContentTypeSerializer typeSerializer, T existingInstance)
… Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateReader.ReadObject[T](ContentSerializerAttribute format)
… Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer.Deserialize[T](XmlReader input, String referenceRelocationPath)
--- Fin de la trace de la pile d'exception interne ---
… Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer.Deserialize[T](XmlReader input, String referenceRelocationPath)
… Microsoft.Xna.Framework.Content.Pipeline.XmlImporter.Import(String filename, ContentImporterContext context)
… Microsoft.Xna.Framework.Content.Pipeline.ContentImporter`1.Microsoft.Xna.Framework.Content.Pipeline.IContentImporter.Import(String filename, ContentImporterContext context)
… MonoGame.Framework.Content.Pipeline.Builder.PipelineManager.ProcessContent(PipelineBuildEvent pipelineEvent)
Lign 6 position 8 is the start of the second <Item>. It seems the </Item> is not accepted, so the second has no sense but I don’t know what to do about that. Is there an other way to serialize/deserialize multidimentionnal arrays ? Am I missing something ?
(The same question stands for int[][][] arrays.)