1
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ You said you have 3 projects. But when you say you have a final class that holds the resources, do you mean a final project that holds the resources? And if that project is where the WORLib.SplashScreen is, is it being built first so that any of the other projects (the Content project) that may build (convert to xnb) something based on it are dealing with an already built assembly? Might be a good idea to add your build order in your question. \$\endgroup\$ Commented Jul 6, 2016 at 11:02
  • \$\begingroup\$ @SteveH fixed, the build order is correct yes, and i did mean projects \$\endgroup\$ Commented Jul 6, 2016 at 20:57

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.