Take the 2-minute tour ×

I have a project which requires an image in the window. This is a static image and i added through 'Add>Existing Item'. It exists in the root of the project.

I reference the image in a test page like so -

<Page x:Class="Critter.Pages.Test"
      <Image Source="bug.png"/>

Problem is I get a message saying it can't be found or it's build action isn't resource but it DOES exist and it's build action IS resource. If i create a new application and just throw it on a window then it works fine.

Any help would be great.

share|improve this question
Is the image in a sub folder? –  JaredPar Mar 12 '09 at 14:29
Nope. the image is in the project root. –  Stimul8d Mar 12 '09 at 14:29
is the build action set to Resource or Embedded Resource ? –  mostlytech Mar 12 '09 at 15:46
add comment

10 Answers

up vote 23 down vote accepted

Try doing a full rebuild, or delete the build files and then build the file.

Visual Studio doesn't always pick up changes to resources, and it can be a pain to get it recompile.

Also try using a full URI as that helped me when I had the same problem. Something like

share|improve this answer
Thanks dude. that worked a treat! Still don't really get those Pack URIs but the full rebuild did the trick. –  Stimul8d Mar 13 '09 at 9:22
add comment

I had the same issue. Cleaning and rebuilding the solution didn't fix it so I restarted visual studio and it did. Here's hoping Visual 2010 fixes this issue and the many others that plauge wpf in Visual 2008.

share|improve this answer
Thank you - that was the solution! –  Stiefel Jun 23 '10 at 13:56
add comment

--> Right click the image file --> Click property --> Select Build Action to Resource --> Clean and Build solution --> Run the Solution You will get the all


share|improve this answer
add comment

Try starting the path to your image with a "/":

<Image Source="/bug.png"/>
share|improve this answer
interesting only this solution works! –  JXITC Jun 27 '12 at 16:41
I think this might be the solution when the view xaml is in another subfolder, if starting with a forward slash indicates an absolute uri (successful) instead of a relative one (unsuccessful). –  Factor Mystic Sep 23 '12 at 22:33
add comment

It doesn't, or at least the current beta doesn't. I found this page while looking into exactly the same problem. Rebuild/clean did nothing. After closing down and reloading the solution the file magically became compatible again.

share|improve this answer
add comment

it does exactly solve the problem, the restart of vs 2008. hope there will be developing a patch at least to address this

share|improve this answer
add comment

There is a solution to your question

<Image Source="/WpfApplication4;component/images/sky.jpg" />

"component" is not a folder!

share|improve this answer
add comment

Example of async load, another option. Example clip.mp4 is in the web project root.

void Landing_Loaded(object sender, RoutedEventArgs e)
    //Load video async

    Uri pageUri = HtmlPage.Document.DocumentUri;
    Uri videoUri = new UriBuilder(pageUri.Scheme, pageUri.Host, pageUri.Port, "clip.mp4").Uri;           

    WebClient webClient = new WebClient();
    webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(webClient_OpenReadCompleted);

void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
    byte[] VideoBuffer = new byte[e.Result.Length];
    e.Result.Read(VideoBuffer, 0, (int)e.Result.Length);
    MemoryStream videoStream = new MemoryStream(VideoBuffer);
share|improve this answer
add comment

I had a similar problem. After I deleted a someStyle.xaml file that I wasn't really using from the solution explorer. Then I restored the file, but no change happened. Cleaning and rebuilding the project did not help.

Simply deleting the corresponding row:

<ResourceDictionary Source="someStyle.xaml"/> 

did the trick.

share|improve this answer
add comment

I had the same error message but my issues was a simple NOOB mistake.

When I added my .ico files to "My Project / Resources", VS made a sub folder named Resources and I was trying to use;

<Window Icon="icons1.ico">

when I should have been using;

<Window Icon="Resources/icons1.ico">

... don't judge, I started using WPF 1 week ago :)

share|improve this answer
add comment

Your Answer


