Content.Load<Texture2D> throwing File Not Found Exception

I started a new project for Windows Phone 7 today, my first XNA project on the phone.

After a bit of twiddling with a level generating algorithm I decided I wanted to do my first drawing on the screen. So I created an XNA project and started to write the rendering plumbing.

After following some guides I managed to get the basics up pretty quickly, so I drew some tiles to be used for tests and imported them into the Content of the project.

But at the first test I got an exception, trying to load these tiles with Content.Load<Texture2D> produced a File Not Found Exception.

I searched for answers, but it looked like I was doing exactly what every one else was doing, other than that my code was apparently not working.

The solution

After some head-scratching I finally noticed I had entered my resource names with the file type ending(.png to be precise) and that is a no-no when using the content pipeline, as it rebuilds the files in to the .xnb format. So no file name endings on assets!

Happy coding!

Check out some other XNA articles here

SuppressDraw in mixed XNA / Silverlight projects on Windows Phone
XML serialization in the Silverlight / XNA template for Windows Phone 7.1

XNA Error loading content, file not found
Tagged on:     

16 thoughts on “XNA Error loading content, file not found

  • January 28, 2011 at 18:25
    Permalink

    thanks for the useful article. greets

    Reply
    • July 14, 2011 at 09:38
      Permalink

      Now I’m like, well duh! Truly tnhafkul for your help.

      Reply
  • March 11, 2011 at 14:11
    Permalink

    Seems simple when you think of it 😉

    Reply
    • March 28, 2011 at 18:21
      Permalink

      It does, doesn’t it!

      Reply
  • May 3, 2011 at 21:00
    Permalink

    I thought you were about to solve my problem, but… 🙁 My problem is the same like yours, but i do have removed the file extension from asset name and my application doesn’t run yet 🙁 I’m goind mad with this xD

    Reply
    • May 3, 2011 at 23:38
      Permalink

      Doh, sorry to hear that 🙁
      Do you have them located in any folders with funky paths perhaps?

      Reply
  • July 19, 2011 at 23:43
    Permalink

    im finding myself in the same position but even this one is exactly the way i have it written… but its still throwing me the exception
    stick = Content.Load(“stick”);

    Reply
  • September 22, 2011 at 21:46
    Permalink

    it that soution dosen’t work. what’s going on with my code?

    Reply
    • September 22, 2011 at 23:06
      Permalink

      What kind of error are you getting?

      Reply
      • September 29, 2011 at 16:55
        Permalink

        Error loading “fondoUniversidad”. File not found.
        this part of the code:fondo_t = Content.Load(“fondoUniversidad”);

        the file is in the corect folder,all is in the correct place.

        Reply
        • September 29, 2011 at 18:57
          Permalink

          If the asset name you are loading is named “Universidad” and the folder name is “fondo”, the code should probably look like this in c#:

          fondo_t = Content.Load(“fondo/Universidad”);

          Reply
          • September 30, 2011 at 02:07
            Permalink

            no,it dosen’t work,another solution?

          • September 30, 2011 at 11:20
            Permalink

            Have you verified that you got the correct asset name? If not you can just check properties on the “Universidad” file and make sure what it’s asset name is.

            If the asset name is correct make sure you have a content reference to the content project, because you will see that exact same error if the reference has been dropped some how.

  • Pingback: SuppressDraw in mixed XNA / Silverlight projects on Windows Phone

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.