0
votes

This is embarrassing. It is a file not found problem with my XNA + Silverlight project.

I'm modifying the "My Little Teapot" XNA + Silverlight sample for Windows Phone 7, at http://msdn.microsoft.com/en-us/library/ff431744%28v=vs.92%29.aspx and am getting a File Not Found error in OnNavigatedTo() when I merely try to load a texture:

myTex = content.Load("tex1");

(You'll notice this isn't the usual file not found question where the coder is trying to load "tex1.png" instead of "tex1".)

My solution has the same project as in the sample, "sdkMyLittleTeapotCS", and a content project I added, "my content". I added "tex1.png" to the "my content" project, and its asset name is indeed "tex1". Its build action is set to "Compile", and I've tried setting the "Copy to Output Directory" settings to "Do not copy" (which is what works in my normal XNA projects) and also to "Copy if newer".

In all cases I get an exception with a file not found. What is this idiot doing wrong? Thanks in advance!

4

4 Answers

0
votes

Shouldn't the build action be set to Content instead of Compile?

0
votes

Shouldn't your code read :

myTex = content.Load<Texture2D>("tex1");

0
votes

Remove the offending texture from your content project but do not delete it from disk. Then, drag it from an Explorer window back to your content project and make sure the name remains "tex1" - this will force the content project to recreate the associations to the texture - which those associations appear to be bad in their current form.

0
votes

Probably you have the tex1 file in a subfolder. In this case you must provide the full path:

myTex = content.Load<Texture2D>("foldername/tex1");