Search code examples
c#xamarinmonoxnamonogame

Could not load asset as non content


Im trying to load a png file as a test 2d texture. I'm receiving the error

"Could not load testTexture asset as a non-content file!".

I'm loading the png by the Pipline.MacOS application. I've set the platform MacOS and rebuilt it. After building its put in the default Content folder. In the code I've set the root directory to the content folder, then I add the 2d texture. When I run it I get the error

"Microsoft.Xna.Framework.Content.ContentLoadException" - Could not load testTexture asset as a non-content file!

I've checked all the usual things like the platform targeted being correct(this is for MacOS). I'm not sure what else to try and check. I'm using xamarin studio with mono and not the xamarin.mac (mono is free to build). Any help would be great thanks.

public Game1 ()
{
    graphics = new GraphicsDeviceManager (this);
    Content.RootDirectory = "Content";              
    graphics.IsFullScreen = true;       
}

protected override void LoadContent ()
{
    spriteBatch = new SpriteBatch (GraphicsDevice);
    texture = this.Content.Load<Texture2D> ("testTexture");
}

Solution

  • So it seems the issue is with xamarin studio. After preparing the texture through the pipeline, it seems that xamarin hasn't fixed its bug for auto linking the new content with the Content.mgcb subfile/folder. Either that or I've somehow done something wrong. Either way it seems that you have to manually add the file to the folder in the ide. (FYI this doesn't seem to be a issue if your using Visual Studio).