0
votes

I am making a program for a school project and I am new to XNA Game Studio. For some reason even though the file is in Content. I am getting a ContentLoadException occured in Microsoft.Xna.Framework.dll on the code,

spriteSheet = Content.Load<Texture2D>("mario-2");

The code is in the Scene class I created in the initScene function, and the initScene is called after SpriteBatch is created in the LoadContent function on the generated default Game1 class.

I checked the properties of mario-2.png, and the asset name matches the one used and the Content Importer and Content Processer are set to Texture - XNA FrameWork.

Content's RootDirectory was set to "Content" when Game1 was constructed.

1
Is your "mario-2.png" file in the root directory of "Content" or a sub-directory?Jacob Lambert
Its in the root I believe, it is not in any folder within the (Content) section.needoriginalname
Can you show a picture of your solution structure (more specifically, the Content project) and the properties window of the image inside the project?Nahuel Ianni
Here is a picture that show where the exception happened in the code, The project structure, and the image properties. i.imgur.com/m8kCtTM.pngneedoriginalname
And who calls the metod "InitScene"?Nahuel Ianni

1 Answers

0
votes

Check these two things:

1.) Is the image compiled into xnb and in the content folder? I'm not certain that placing the uncompiled image in there will work.

2.) Check the asset name in the properties window of the xnb file to ensure it matches the string you specified in your content.load method.