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
thanks for the useful article. greets
Now I’m like, well duh! Truly tnhafkul for your help.
Nice tip, thanks.
Seems simple when you think of it 😉
It does, doesn’t it!
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
Doh, sorry to hear that 🙁
Do you have them located in any folders with funky paths perhaps?
Thanks
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”);
it that soution dosen’t work. what’s going on with my code?
What kind of error are you getting?
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.
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”);
no,it dosen’t work,another solution?
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