ContentLoadException в MonoGame
Я пытался загрузить текстуру в MonoGame с помощью Xamarin Studio. Мой код настроен как показано ниже:
#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>
/// This is the main type for your 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 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);
//Content
texture = Content.Load<Texture2D>("player");
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update (GameTime gameTime)
{
// For Mobile devices, this logic will close the Game when the Back button is pressed
if (GamePad.GetState (PlayerIndex.One).Buttons.Back == ButtonState.Pressed) {
Exit ();
}
// TODO: Add your update logic here
base.Update (gameTime);
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a 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);
}
}
}
Когда я отлаживаю это, это дает мне ошибку:
Microsoft.Xna.Framework.Content.ContentLoadException: не удалось загрузить ресурс проигрывателя как файл без содержимого! ---> Microsoft.Xna.Framework.Content.ContentLoadException: каталог не найден. ---> System.IO.DirectoryNotFoundException: не удалось найти часть пути 'C: \ Users \ Flame \ Documents \ Projects \ TestGame \ TestGame \ bin \ Debug \ Content \ player.xnb'. ---> System.Exception:
--- Конец внутренней трассировки стека исключений ---
at at System.IO .__ Error.WinIOError (Int32 errorCode, String MaybeFullPath)
at at System.IO.FileStream.Init (Строковый путь, режим FileMode, доступ FileAccess, права Int32, логическое значение useRights, общий ресурс FileShare, параметры типа3232 bufferSize, опции FileOptions, SECURITY_ATTRIBUTES secAttrs, String msgPath, логическое значение bFromProxy, логическое значение useLongPath)
at at System.IO.FileStream..ctor (путь строки, режим FileMode, доступ к FileAccess, общий доступ к FileShare, размер буфера Int32, параметры FileOptions, строка msgPath, логическое значение bFromProxy)
at at System.IO.FileStream..ctor (путь строки, режим FileMode, доступ к FileAccess, общий доступ к FileShare)
at at System.IO.File.OpenRead (String path)
at at Microsoft.Xna.Framework.TitleContainer.OpenStream (имя строки)
на в Microsoft.Xna.Framework.Content.ContentManager.OpenStream (String assetName)
--- Конец внутренней трассировки стека исключений ---
на в Microsoft.Xna.Framework.Content.ContentManager.OpenStream (String assetName)
в at в Microsoft.Xna.Framework.Content.ContentManager.ReadAsset [T] (String assetName, Action`1 recordDisposableObject)
--- Конец внутренней трассировки стека исключений ---
в at в Microsoft.Xna.Framework.Content.ContentManager.ReadAsset [T] (String assetName, Action`1 recordDisposableObject)
на в Microsoft.Xna.Framework.Content.ContentManager.Load [T] (String assetName)
в TestGame.Game1.LoadContent () в c: \ Users \ Flame \ Documents \ Projects \ TestGame \ TestGame \ Game1.cs: 0
на в Microsoft.Xna.Framework.Game.Initialize ()
в TestGame.Game1.Initialize () в c: \ Users \ Flame \ Documents \ Projects \ TestGame \ TestGame \ Game1.cs: 0
на в Microsoft.Xna.Framework.Game.DoInitialize ()
на Microsoft.Xna.Framework.Game.Run (GameRunBehavior runBehavior)
на в Microsoft.Xna.Framework.Game.Run ()
в TestGame.Program.Main () в c: \ Users \ Flame \ Documents \ Projects \ TestGame \ TestGame \ Program.cs: 0
Так что я делаю не так?