Search code examples
c#monogamespritefont

Could not load Spritefont asset as a non-content file


I'm switching a game from to and hit a snag.

I've got my .spritefont file in project_name/Content, it's listed in the solution explorer, and I'm loading it with this line:

debug_font = Content.Load<SpriteFont> ("Kooten");

But I'm getting the error:

"Microsoft.Xna.Framework.Content.ContentLoadException occurred in Monogame.Framework.dll. Could not load Kooten asset as a non-content file!"

What am I missing?


Solution

  • For adding a SpriteFont in , you need to create it in a Content project of an type, compile the game and then copy the generated xnb file over to the project (the file can be located in the output directory path). Then change its properties so that it is set as "Content" and copied to the output folder if newer.

    enter image description here

    You can find the full explanation on this blog.