I developed a towerdefense game that uses xml-Files for almost everything, (creeps, levels, towers, upgrades). Those Xml-files define properties like textures, sounds and values like hitpoints.

My goal is to give the user the power to add and modify those things, which will be some kind of editor in the future probably. For now it shall be notepad...

So this makes using the ContentManager impossible i guess, since it needs to compile the data into those xnb Files.

I dont have a problem to use XmlSerializer, but how does it work for textures or sounds? Do i need to write my own code for loading the texture into vram etc?

Do i need to reinvent the wheel here and write my own ContentManger or can I make use of an existing feature?

I found a few "similiar" questions but none really gave me an answer.

  • \$\begingroup\$ You can read .xml using C# libraries. .png doesn't require compilation to .xnb even though it makes it a bit faster because .xnb is non-compressed format, but .mp3 does require compilation to .xnb. From Monogame MGCB github you can find the source code for the .xnb compiler tool. When I used monogame it had full dependency from XNA pipeline, but I don't know if they changed that. Here it says Removed old XNA content pipeline extensions., but i'm not sure what that means. \$\endgroup\$
    – dimitris93
    May 8, 2015 at 14:05
  • \$\begingroup\$ So your answer is reinvent the wheel ? \$\endgroup\$
    – CSharpie
    May 9, 2015 at 10:50
  • \$\begingroup\$ I wouldn't call it re-invent anything, you are just stuck with the .xnb requirement of Monogame. Its same with every other engine. The code for converting to .xnb is there, you just need to search Monogame MGCB github I linked you, and also see which .dll dependencies this code has, add that .dll to your content folder and add it as Reference in visual studio, so that when you publish your game, people won't have to download something extra, since the .dll will be inside your content folder. \$\endgroup\$
    – dimitris93
    May 9, 2015 at 15:19

1 Answer 1


There are some workarounds to this problem without needing to completely reinvent the wheel. For example, you should be able to load any file from any location using the TitleContainer.OpenStream method.

Then, once you have the stream you can convert it into a Texture2D.FromStream method. Of course, you'll need to do your own research to figure out how to load each of the different content types and some of them may not be supported on all platforms.

Perhaps something like this (untested):

using(var stream = TitleContainer.OpenStream("your-file.png"))
    return Texture2D.FromStream(GraphicsDevice, stream);
  • 1
    \$\begingroup\$ I ended up doing this, I had to overwrite the ContentManager (Load<T> Method) and implemented all the things there (Calling some custom ContentFactory). I also add the Objects to the LoadedAssets-Dictionary to use the "regular" caching mechanism. \$\endgroup\$
    – CSharpie
    May 11, 2015 at 10:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .