I have followed the tutorial at https://docs.monogame.net/articles/getting_started/4_adding_content.html , but running it gives the error ‘Microsoft.Xna.Framework.Content.ContentLoadException: ‘The content file was not found.’’. Code for Game1.cs below:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace MonoGame_Test
{
public class Game1 : Game
{
private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch;
Texture2D ballTexture;
public Game1()
{
_graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
IsMouseVisible = true;
}
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
protected override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
ballTexture = Content.Load<Texture2D>("ball");
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
// TODO: Add your update logic here
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
_spriteBatch.Begin();
_spriteBatch.Draw(ballTexture, new Vector2(0, 0), Color.White);
_spriteBatch.End();
base.Draw(gameTime);
}
}
}
The content.mgcb contains the correct file: https://i.gyazo.com/687ee6466ffd12e3aad527d46dfe4936.png
What am I missing here?
Edit1: Solved: Needed to rebuild project solution first.