Problem with loading content

Hey everyone,
today I started using MonoGame and directly faced an error whilst loading a 2DTexture. The error, that I am receiving is the following: Microsoft.Xna.Framework.Content.ContentLoadException.
I already tried to look a bit around and fix it but it have not worked out so far. Maybe something is wrong with executing the whole thing in Debug mode, since the output directory of it is bin\debug? In the following, you can see a screenshot of my code and the folder hierarchy.


~JackboyPlay

Remove .png from the content name in the source code.

1 Like

Yeah, I thought the same at the first moment, but it have not worked either. But thanks! :slight_smile:

If you don’t use MGCB, then you will need to use something like this:

FileStream fileStream = new FileStream([filename], System.IO.FileMode.Open);
texture = Texture2D.FromStream(graphics.GraphicsDevice, fileStream);

I have used this in the past to load different PNG’s in an editor.

1 Like

As has been pointed out, you don’t include the extension when loading content. However, can you also confirm that the asset is in that same directory path relative to your Content.mgcb file. Finally, please confirm that you’ve added that asset to your Content.mgcb file.

When you open Content.mgcb in the MonoGame Pipeline Tool, I’d expect to see something like the following…

image

(Except your texture would be in a folder called “Character”).

1 Like

Thanks to everyone for helping me out with this issue! I used the option from @etrain01 to solve my problem. Furthermore, I had to set my pictures as resources in MonoDevelop, which I forgot before.
~JackboyPlay