Could not load Spritefont asset as a non-content file

3.4k Views Asked by At

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?

3

There are 3 best solutions below

2
Nahuel Ianni On BEST ANSWER

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.

2
Dan Teesdale On

Under solution explorer, click and highlight the file. In the file properties make sure the "Build Action" drop-down has "Content" selected.

0
SteveProXNA On

Don't forget to Rebuild solution after making these changes...!