Recently I have been having some troubles loading assets as Texture2D. I have tried changing the path to "..\assetName", "assetName", "assetName.png" and "..\assetName.png" (as suggested by one of the answers to this question but neither of them does the job. I have also tried using the MonoGame content pipeline when adding the file and the "Copy to Output Directory" parameter is currently set to "Copy Always".
I tried creating a new project with some really simple code for loading the content file and it reads as follows
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace TempSol2
{
/// <summary>
/// This is the main type for your game.
/// </summary>
public class Game1 : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Texture2D texture;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
texture = Content.Load<Texture2D>("Character1");
}
But I get the same error every time.
The exception message reads as the title says "Could not load Character1 asset as a non-content file" and the inner exception says "The content file was not found."
I have also checked the folder where the file is supposed to be copied to and it contains both the .png and the .xnb