0

I'm working with MonoGame and I want to use XMLs to attach some metadata for some of my textures. I created the following class:

    public class TextureData
    {
        public float FrameWidth;
        public float FrameHeight;
    }

And now I'm trying to create an XML in my content pipeline and load it. I tried writing the following XML:

<?xml version="1.0" encoding="utf-8"?>
<XnaContent xmlns:ns="Microsoft.Xna.Framework">

  <Asset Type="TextureData">
    <FrameWidth>0.2</FrameWidth>
    <FrameHeight>0.2</FrameHeight>
  </Asset>

</XnaContent>

And got the following error:

error : Importer 'XmlImporter' had unexpected failure!
1>  Microsoft.Xna.Framework.Content.Pipeline.InvalidContentException: Could not resolve type 'TextureData'.

I read some tutorials and in all of them whenever they use custom type they take it from external dll and reference to it. So I tried moving the class to external dll and use it from there and it works. However, it feels very messy to create a whole class library inside my original project just to reference a class from XML..

So my question is this: is it possible to use custom type from the MonoGame project itself inside XML content? eg without external dll with reference?

Thanks!

Ronen Ness
  • 9,923
  • 4
  • 33
  • 50
  • 1
    It is not messy at all to separate one central game project into a few. My own game has an Engine.csproj, that is built on the idea "What is not unique to this game? And can another game use it?" I also use about 6 content pipeline extensions, an Engine project is very useful. – Jarryd Nov 30 '16 at 10:50
  • @Jarryd I agree its not messy at all in your case, but I'm writing a gui lib that comes as a dll.. so now instead of one dll + content its 2 dlls + content + need to add reference to one of the dlls. – Ronen Ness Nov 30 '16 at 11:50

1 Answers1

0

You could compile MonoGame from source, but have it in the same project as your UI project. Maybe just grab the types you need, like Vector2 and Point etc...

Jarryd
  • 572
  • 4
  • 13
  • Hi Jarryd, my question specifically state **without external dll**, and its even in bold :). Anyway I already understood from the MG forum that its impossible due to the content building process. I cannot accept your answer as it is, because it doesn't really address the question and don't add any useful data. But if you want to improve it a little I'll be happy to accept and upvote. – Ronen Ness Nov 30 '16 at 12:03