XNA Error loading content, file not found

Content.Load<Texture2D> throwing File Not Found Exception

A screenshot of Visual Studio 2010 showing the add existing content menu choise

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

Related posts: