c# - ContentLoadException in MonoGame -


i've been trying load texture in monogame using xamarin studio. code set below :

#region using statements using system;  using microsoft.xna.framework; using microsoft.xna.framework.graphics; using microsoft.xna.framework.storage; using microsoft.xna.framework.input;  #endregion  namespace testgame {     /// <summary>     /// main type game     /// </summary>     public class game1 : game     {         graphicsdevicemanager graphics;         spritebatch spritebatch;          //game world         texture2d texture;         vector2 position = new vector2(0,0);          public game1 ()         {             graphics = new graphicsdevicemanager (this);             content.rootdirectory = "content";                           graphics.isfullscreen = false;               }          /// <summary>         /// allows game perform initialization needs before starting run.         /// can query required services , load non-graphic         /// related content.  calling base.initialize enumerate through components         /// , initialize them well.         /// </summary>         protected override void initialize ()         {             // todo: add initialization logic here             base.initialize ();          }          /// <summary>         /// loadcontent called once per game , place load         /// of content.         /// </summary>         protected override void loadcontent ()         {             // create new spritebatch, can used draw textures.             spritebatch = new spritebatch (graphicsdevice);              //content             texture = content.load<texture2d>("player");         }          /// <summary>         /// allows game run logic such updating world,         /// checking collisions, gathering input, , playing audio.         /// </summary>         /// <param name="gametime">provides snapshot of timing values.</param>         protected override void update (gametime gametime)         {             // mobile devices, logic close game when button pressed             if (gamepad.getstate (playerindex.one).buttons.back == buttonstate.pressed) {                 exit ();             }             // todo: add update logic here                      base.update (gametime);         }          /// <summary>         /// called when game should draw itself.         /// </summary>         /// <param name="gametime">provides snapshot of timing values.</param>         protected override void draw (gametime gametime)         {             graphics.graphicsdevice.clear (color.cornflowerblue);              //draw              spritebatch.begin ();             spritebatch.draw (texture, position, color.white);             spritebatch.end ();              base.draw (gametime);         }     } } 

when debug it gives me error :

microsoft.xna.framework.content.contentloadexception: not load player asset non-content file! ---> microsoft.xna.framework.content.contentloadexception: directory not found. ---> system.io.directorynotfoundexception: not find part of path 'c:\users\flame\documents\projects\testgame\testgame\bin\debug\content\player.xnb'. ---> system.exception:

--- end of inner exception stack trace ---

at @ system.io.__error.winioerror(int32 errorcode, string maybefullpath)

at @ system.io.filestream.init(string path, filemode mode, fileaccess access, int32 rights, boolean userights, fileshare share, int32 buffersize, fileoptions options, security_attributes secattrs, string msgpath, boolean bfromproxy, boolean uselongpath)

at @ system.io.filestream..ctor(string path, filemode mode, fileaccess access, fileshare share, int32 buffersize, fileoptions options, string msgpath, boolean bfromproxy)

at @ system.io.filestream..ctor(string path, filemode mode, fileaccess access, fileshare share)

at @ system.io.file.openread(string path)

at @ microsoft.xna.framework.titlecontainer.openstream(string name)

at @ microsoft.xna.framework.content.contentmanager.openstream(string assetname)

--- end of inner exception stack trace ---

at @ microsoft.xna.framework.content.contentmanager.openstream(string assetname)

at @ microsoft.xna.framework.content.contentmanager.readasset[t](string assetname, action`1 recorddisposableobject)

--- end of inner exception stack trace ---

at @ microsoft.xna.framework.content.contentmanager.readasset[t](string assetname, action`1 recorddisposableobject)

at @ microsoft.xna.framework.content.contentmanager.load[t](string assetname)

at testgame.game1.loadcontent() in c:\users\flame\documents\projects\testgame\testgame\game1.cs:0

at @ microsoft.xna.framework.game.initialize()

at testgame.game1.initialize() in c:\users\flame\documents\projects\testgame\testgame\game1.cs:0

at @ microsoft.xna.framework.game.doinitialize()

at @ microsoft.xna.framework.game.run(gamerunbehavior runbehavior)

at @ microsoft.xna.framework.game.run()

at testgame.program.main() in c:\users\flame\documents\projects\testgame\testgame\program.cs:0

so doing wrong?

set 'build action' of png file 'content' , set 'copy output directory' 'copy if newer'.

you can bring properties window in xamarin studio ctrl clicking file , pressing properties.

you shouldn't include file extension.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -