1
votes

I'm having a problem building some XML files for a game using Monogame v3.5 content pipeline tool. I have two projects specifically for data - one for generic data classes and ones for specific data classes - which I then reference into my game.

All the XML files which use the 'generic' data classes build correctly, but the XML files which use the game specific data classes do not. I have added references to both project dlls in my .mgcontent project; also, the game specific data project references the generic data project.

I obtain the following error when building using the pipeline tool:

Importer 'XmlImporter' had unexpected failure! Microsoft.Xna.Framework.Content.Pipeline.InvalidContentException: Could not resolve type 'SpaceCardGameData.SpaceBackgroundData'

The Xml file for the above failed file is:

<XnaContent>
    <Asset Type="SpaceCardGameData.SpaceBackgroundData">
        <AsteroidTextureAssets>
            <Item>Objects\Asteroids\TinyAsteroid</Item>
            <Item>Objects\Asteroids\SmallAsteroid</Item>
            <Item>Objects\Asteroids\LargeAsteroid</Item>
            <Item>Objects\Asteroids\HugeAsteroid</Item>
        </AsteroidTextureAssets>
    </Asset>
</XnaContent>

and .cs file is:

namespace SpaceCardGameData
{
    public class SpaceBackgroundData : BaseData
    {
        public List<string> AsteroidTextureAssets { get; set; }
    }
}

(Base Data is an empty class in the 'generic' project I just use as a base type for templating and so forth).

Does anyone have an idea why the XML files for one project are working, but not for the other. If you wish to see anything else, I will upload it. Thanks.

1
See my solution on following posting. Look at the property 'XmlInclude' : stackoverflow.com/questions/32700342/…jdweng
Your answer doesn't seem to be related to the MonoGame Content Pipeline, just generic XML deserialization. I also don't believe there should be any markup attributes required for the data file and I don't think that is what is causing the error - the pipeline cannot find the game specific data 'SpaceCardGameData.SpaceBackgroundData' type, rather than the BaseData class.Alan Wills
I don't know MonoGame, but I suspect that MonoGame is using the standard Net serialization with some enhancements.jdweng
As I've said, I am confident this is not a formatting issue of either my XML or my .cs files, because one set of XML data files works correctly. The only difference with the set that do not work is that they are in a different project, which leads me to suspect there is referencing I am missing somewhere.Alan Wills
The 'type' attribute is probably the issue. It is related to the XmlInclude property in the posting I referenced. The type needs to be consistent with the BaseData class.jdweng

1 Answers

0
votes

FIXED It turns out that the project with the data files that were not working was not a true Windows class library, but rather a Monogame project where I had deleted the Game.cs class to save myself having to add references. This is what broke it. Data projects MUST be true Class libraries it seems.