The content file was not found

Hi all,

I got this error message in latest monogame (3.8.1) test project.
The content file was not found

var icon = Content.Load<Texture2D>("icon");

Any ideas?
Thanks

Where is the error message?

my load lines look more like this

icon = content.load<texture2d>(path+file)

The content file was not found

Have you set the drop-down menu for the xnb to content + copy if newer?


Should be “./icon” not “icon”

i.e.:
var icon = Content.Load<Texture2D>("./icon");

I tried it. Same result. not working

This isn’t the xnb file. The Content.mgcb is suppsoed to take the icon.png file and transform it into a icon.xnb file. You need to verify the existence of that file.

Yes .xnb there.

That’s not the folder it’s executing from though. Go into file explorer, it should be something like Project\bin\Debug\net6.0\Content. Make sure it’s there. Open the content builder, and build the file in there. Maybe it’s not configured to build from your IDE. If it is not there, and it is not going there when you build it in MGCB, you need to set Config and OutputDir to the right folders in MGCB. Click on the red “Content” icon in the top left of MGCB, you’ll see those parameters listed there.

Thanks for the reply. Yes, that file is not there see the image
image

This is my MGCB configurations
image

This is how I have mine set up, see if this works for you:

ss

Basically you need to set it up so that your Content folder is outputting to your build folder which for you looks like it is net6.0-android. So you would replace net6.0 in my config with net6.0-android in yours.

When you build release you’ll have to change that “Config” parameter to Release instead of Debug.

For desktop projects your content needs to be next to the executeable files in the bin folder. With Android it’s different. The content files need to be deployed first. I think it deploys them from this folder (at least in my case, which is probably default):
\obj\Debug\net6.0-android\assets\Content

I set MGCB settings as below. Now it’s working. Thanks All
image

1 Like