IntermediateSerializer not working?

Hi Guys,

I’m using the IntermediateSerializer to serialize and deserialize some files but I got no result from either method, no exception, no file data after serialization and no object instance on deserialization…

From further inspection of the IntermediateSerializer class using a decompiler I can see that the class is actually just a skeleton, the methods are empty. I got the dll from nuget: MonoGame.Framework.Content.Pipeline.Portable 3.6.0.1625

After some research I saw that the dll included in the MSBuild contains the actual implementation and that one works to a certain degree, throwing this exception:

System.NotImplementedException: Unhandled primitive type System.Single!
at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer.GetTypeSerializer(Type type)
at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.ReflectiveSerializer.GetElementInfo(IntermediateSerializer serializer, MemberInfo member, ElementInfo& info)
at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.ReflectiveSerializer.Initialize(IntermediateSerializer serializer)
at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer.GetTypeSerializer(Type type)
at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateReader.ReadObject[T](ContentSerializerAttribute format)
at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer.Deserialize[T](XmlReader input, String referenceRelocationPath)

Is the nuget package supposed to be like that? Or I’m doing something wrong…?

Thanks for any help.

Can you provide the file you’re trying to compile?

It’s a pain, but in the past when I had problems with the intermediateSerializer, I pulled the content pipeline project from GitHub and linked it to my own project instead of using the DLL so I could step through it and get a more meaningful error.
You can even create a little stripped down project that just serializes/deserializes your files to your custom types, link the GitHub project for the content pipeline, and step through as well.

I really hope that helps.

The compilation works fine using the pipeline tool. It can compile the xml files and they load in an android project just fine.

The issue is generating the xml files using the IntermediateSerializer.

Just using the following code:

XmlWriterSettings settings = new XmlWriterSettings()
{
Indent = true
};

        using (XmlWriter writer = XmlWriter.Create("c://test", settings))
        {
            IntermediateSerializer.Serialize(writer, "string", null);
        }

Does not work. Using the nuget package MonoGame.Framework.Content.Pipeline I get an empty file, with no exceptions and when using the dll from the monogame folder in MSBuild I get the following exception:

System.NotImplementedException occurred
Message=Unhandled primitive type System.Char!
Source=MonoGame.Framework.Content.Pipeline
StackTrace:
at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer.GetTypeSerializer(Type type)
at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.ReflectiveSerializer.GetElementInfo(IntermediateSerializer serializer, MemberInfo member, ElementInfo& info)
at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.ReflectiveSerializer.Initialize(IntermediateSerializer serializer)
at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer.GetTypeSerializer(Type type)
at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.NamespaceAliasHelper.GetAllUsedNamespaces[T](T value)
at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.NamespaceAliasHelper.WriteNamespaces[T](XmlWriter writer, T value)
at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer.Serialize[T](XmlWriter output, T value, String referenceRelocationPath)

This happens in a Windows Forms project with .NET 4.5 and also on a WPF project with .NET 4.5 and 4.5.1.

That is what I ended up doing, I downloaded the project from github and added a reference to this project instead of the dll and the code now works fine.

Thanks for your input.