Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8648559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:20:28+00:00 2026-06-12T13:20:28+00:00

Possible Duplicate: XNA – File not found problem Here I am trying to load

  • 0

Possible Duplicate:
XNA – File not found problem

Here I am trying to load a Round.png file in windows phone 7 application project. I don’t know how to load this image during run time. I am really sorry if this is a silly question as i m a newbie in windows app development. Please help…
Thanks in advance!!!

     /// <summary>
     /// This is the main type for your game
     /// </summary>
   public class Game1 : Microsoft.Xna.Framework.Game
   {
    GraphicsDeviceManager graphics;
    SpriteBatch spriteBatch;
    Texture2D texRound;
    Rectangle HitRegion;
    bool isSelected = false;

    TouchCollection touches = TouchPanel.GetState();

    //start position of round, in the center of screen
    int positionX = 400;
    int positionY = 240;

    //random number Axis X and Y
    Random randomX;
    Random randomY;

    //the range for random number of start and end of X, Y
    int startX, endX;
    int startY, endY;

    //total time
    float milliseconds = 0f;

    //score count
    int count = 0;

    //game font
    SpriteFont font;

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

        // Frame rate is 30 fps by default for Windows Phone.
        TargetElapsedTime = TimeSpan.FromTicks(333333);

        // Extend battery life under lock.
        InactiveSleepTime = TimeSpan.FromSeconds(1);
    }

    /// <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);
        texRound = Content.Load<Texture2D>("Round");
        randomX = new Random();
        randomY = new Random();

        // The X axis bound range of touch for ball
        startX = texRound.Width;
        endX = GraphicsDevice.Viewport.Width - texRound.Width;

        // The X axis bound range of touch for ball
        startY = texRound.Height;
        endY = GraphicsDevice.Viewport.Height - texRound.Height;

        // Define the HitRegion of ball in the middle of touchscreen
        HitRegion = new Rectangle(positionX - texRound.Width / 2,
        positionY - texRound.Height / 2, texRound.Width,
        texRound.Height);

        // Load the font definition file
        font = Content.Load<SpriteFont>("gamefont");

        // TODO: use this.Content to load your game content here
    }

    /// <summary>
    /// UnloadContent will be called once per game and is the place to unload
    /// all content.
    /// </summary>
    protected override void UnloadContent()
    {
        // TODO: Unload any non ContentManager content here
    }

    /// <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)
    {
        // Allows the game to exit
        if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            this.Exit();

        // TODO: Add your update logic here

        // Accumulate the elapsed milliseconds every frame
        milliseconds +=
        (float)gameTime.ElapsedGameTime.TotalMilliseconds;
        if (milliseconds > 1000)
        {
            // When the milliseconds greater than 1000 milliseconds,
            // randomly locate a new position for the ball
            HitRegion.X = randomX.Next(startX, endX + 1);
            HitRegion.Y = randomY.Next(startY, endY + 1);
            // Reset the milliseconds to zero for new milliseconds
            // count
            // make the ball not been selected
            milliseconds = 0f;
            if (isSelected)
                isSelected = false;
        }
        base.Update(gameTime);

        Point touchPoint = new Point((int)touches[0].Position.X, (int)touches[0].Position.Y);
        if (HitRegion.Contains(touchPoint))
        {
            isSelected = true;
            count++;
        }
        else
        {
            isSelected = false;
        }
    }

    /// <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)
    {
        GraphicsDevice.Clear(Color.Green);

        // TODO: Add your drawing code here

        spriteBatch.Begin();
        if (isSelected)
        {
            spriteBatch.Draw(texRound, HitRegion, Color.Red);
        }
        else
        {
            spriteBatch.Draw(texRound, HitRegion, Color.White);
        }
        spriteBatch.DrawString(font, "Score:" + count.ToString(),
        new Vector2(0f, 0f), Color.White);
        spriteBatch.End();

        base.Draw(gameTime);
    }
}

Error Details

this is the error message

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:20:29+00:00Added an answer on June 12, 2026 at 1:20 pm

    The path in the inner exception looks correct: \"Content\\Round.xnb\", the extra slashes are just because it’s escaped. This is a relative path from your executable, be default it’s something like: Visual Studio Projects\MyCoolGame\MyCoolGame\bin\x86\Debug\Content\Round.xnb. You should be comparing this path to the the real path to the Round.xnb file, not the png.

    • If Round.xnb does not exist anywhere, then your png file isn’t part of Content project, or the Content project isn’t being built
    • If the file does exist, but is in a subdirectory, specify the name of the subdirectory when you load the texture like: Content.Load<Texture2D>("myDir\\Round");

    Since the inner exception isn’t looking for “Round.png.xnb”, you have your names up correctly and @Ricket’s answer won’t help you any further.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Problem when loading php file into variable (Load result of php code
Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: Please tell me about this XNA development problem on DELL inspiron !
Possible Duplicate: WAMP Stack PHP Fatal error: Class ‘SoapClient’ not found I downloaded a
Possible Duplicate: how to add a reference to the system.data.SQLite.dll to the windows phone
Possible Duplicate: Max file number can php upload at same time I'm trying to
Possible Duplicate: XNA Mouse Movement Basically, I am creating a game using XNA, and
Possible Duplicate: Objective C for Windows iPhone development on Windows Is there any way
Possible Duplicate: Why is String.Concat not optimized to StringBuilder.Append? One day I was ranting
Possible Duplicate: Comparison between XNA and DirectX (C#) The subject speaks for itself. Does

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.