Skip to main content
3 of 3
replaced http://gamedev.stackexchange.com/ with https://gamedev.stackexchange.com/

XNA Deserialization Error: XML element "Type" not found

I want to deserialize an xml file that contains a path for an image I have 3 projects:

One with the Program.cs class and the main template stuff from xna,

another with classes such as the default 'Game1" as well as others,

and a final project containing the resources.

The build order is: Classes -then-> resources + Program.cs last Resources (the xml) depends on the classes, and program also depends on classes

Here is a screenshot of the solution explorer: https://i.sstatic.net/QBAGC.jpg (Game1 is renamed to Main.cs)

Here is the class which loads the image:

namespace WORLib
{
    class SplashScreen : GameScreen
    {
        Texture2D image;

        public string Path;

        public override void LoadContent()
        {
            base.LoadContent();
            image = content.Load<Texture2D>(Path);
        }
...

Here is the class that manages the screens:

namespace WORLib
{
    class ScreenManager
    {
        //fields
        public static ScreenManager instance;
        public Vector2 Dimensions { private set; get; }
        public ContentManager Content { private set; get; }
        XmlManager<GameScreen> xmlGameScreenManager;

        GameScreen currentScreen;

        public static ScreenManager Instance
        {
            get
            {
                if (instance == null)
                    instance = new ScreenManager();
                return instance;
            }
        }

        private ScreenManager()
        {
            Dimensions = new Vector2(640, 480);
            currentScreen = new SplashScreen();
            xmlGameScreenManager = new XmlManager<GameScreen>();
            xmlGameScreenManager.Type = currentScreen.Type;
            currentScreen = xmlGameScreenManager.Load("SplashScreen.xml");
        }
...

This is the xml code:

<?xml version="1.0" encoding="utf-8"?>
<XnaContent xmlns:ns="WORLib">
  <Asset Type="WORLib.SplashScreen">
    <SplashScreen>
      <Path>SplashScreen/image</Path>
    </SplashScreen>
  </Asset>
</XnaContent>

And this is the error I get upon building:

XML element "Type" not found

This error does not appear in any thread ive found anywhere, and most other threads did not get me very far. This thread: C# XNA - Can't Deserialize Element helped me the most, but I did not know how to get rid of the xnamanager class without breaking my content loading.