So I keep getting this error when attempting to load an XML file encoded by the IntermediateSerializer. I expect the error is mine rather than a bug in Monogame, but I can’t figure it out. However, I’m not ruling out the Monogame bug, especially since I’m in an odd situation as far as platforms.
Anyway, the error:
2> E:/extra programming/C# Projects/PCSK/CityEditor/Content/cities.xml
2>EXEC : warning : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
2>E:/extra programming/C# Projects/PCSK/CityEditor/Content/cities.xml : error : Importer 'XmlImporter' had unexpected failure!
2> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
2> at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
2> at System.Reflection.Assembly.GetTypes()
2> at System.Linq.Enumerable.<SelectManyIterator>d__22`3.MoveNext()
2> at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
2> at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
2> at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer.FindType(String typeName)
2> at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
2> at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
2> at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
2> at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer.FindType(String typeName)
2> at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateReader.ReadObject[T](ContentSerializerAttribute format, ContentTypeSerializer typeSerializer, T existingInstance)
2> at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateReader.ReadObject[T](ContentSerializerAttribute format)
2> at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer.Deserialize[T](XmlReader input, String referenceRelocationPath)
2> at Microsoft.Xna.Framework.Content.Pipeline.XmlImporter.Import(String filename, ContentImporterContext context)
2> at Microsoft.Xna.Framework.Content.Pipeline.ContentImporter`1.Microsoft.Xna.Framework.Content.Pipeline.IContentImporter.Import(String filename, ContentImporterContext context)
2> at MonoGame.Framework.Content.Pipeline.Builder.PipelineManager.ProcessContent(PipelineBuildEvent pipelineEvent)
2>C:\Program Files (x86)\MSBuild\MonoGame\v3.0\MonoGame.Content.Builder.targets(90,5): error MSB3073: The command ""C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools\MGCB.exe" /@:"E:\extra programming\C# Projects\PCSK\CityEditor\Content\Content.mgcb" /platform:Windows /outputDir:"E:\extra programming\C# Projects\PCSK\CityEditor\Content\bin\Windows" /intermediateDir:"E:\extra programming\C# Projects\PCSK\CityEditor\Content\obj\Windows" /quiet" exited with code 1.
I have no idea how to “retrieve the LoaderExceptions property” so I can’t get that information.
The serialized class was a List of a custom type, and the XML file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<XnaContent xmlns:Generic="System.Collections.Generic">
<Asset Type="Generic:List[WrathOfTheGods.City]">
<Item>
<Name>sdfg</Name>
<Region>fffffffffffffffffffff</Region>
<position>273 283</position>
<neighbors>1 2</neighbors>
</Item>
<Item>
<Name>we</Name>
<Region>eiiiiiiiiiiiiii</Region>
<position>419 239</position>
<neighbors>0</neighbors>
</Item>
<Item>
<Name>yo</Name>
<Region>yoma</Region>
<position>227 387</position>
<neighbors>0</neighbors>
</Item>
</Asset>
</XnaContent>
(Uh… excuse the odd strings, I got a little keyboard flaily after doing so many tests leading up to this.)
So that file seems straightforward enough. The class is of course a little less so but still fine I should think:
([Usings excluded])
namespace WrathOfTheGods
{
public class City
{
[ContentSerializer]
public string Name
{ get; private set; }
[ContentSerializer]
public string Region
{ get; private set; }
public Vector2 Position
{
get
{
return new Vector2(position.X, position.Y);
}
}
[ContentSerializer]
private Vector2 position;
[ContentSerializer]
private List<int> neighbors;
private List<City> cityList;
([Methods excluded])
}
}
It doesn’t serialize that last list of course, but that’s by design. (Ish.)
Anyway so the thing that might be causing problems is that the project that I’m trying to deserialize into (and the one I serialized from) is a Windows(DX) project, but the project that actually encodes the class is an Android project. (The Windows project is an editing tool.) I’ve got references set up and all, of course, but the cross platforming has caused some oddness before (it tries to run the Windows project in the android emulator if my tablet isn’t plugged in :? ). But I’ve given the pipeline tool a reference to the version of the .dll that’s in the Windows project’s bin folder, so…?
Anyway, thanks for reading, please help if you can.
EDIT: Well, I’ve confirmed that it’s not to do with the List - I serialized a single City and it can’t load that either. (I also tried removing the List from the City class, which also didn’t help.)
This is really quite frustrating. I cannot find any possible reason why this isn’t working - unless it’s just due to different platforms, which doesn’t seem like it should effect it. (Or, perhaps I should say, I can find plenty of possible reasons - but none of them seem to be it.)