5

I get the error

The file /DocomGUI;component/Resources/logo.jpg is not part of the project or its 'Build Action' property is not set to 'Resource'.

But the logo.jpg file is definitely part of the project and the Build Actions is also set to "Resource".

Project structure File properties

It resides within the /Resources/ folder in the root of the project and is also in the Resources.resx file with the same name.

Resources file

I tried rebuilding the solution, cleaning it and still, the error pops up. What else could go wrong so that the file can't be found?

The code:

<Window x:Class="DocomGUI.AboutWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="AboutWindow" Height="180" Width="220" Background="LightGray" MinWidth="220" MinHeight="115" MaxWidth="220" MaxHeight="115">
    <Grid>
        <Label Margin="0,66,24,48">DocomGUI</Label>
        <Label Height="30" Margin="12,0,12,12" Name="VersionLabel" VerticalAlignment="Bottom"></Label>
        <Image Margin="12,12,12,0" Stretch="Fill" Height="48" VerticalAlignment="Top" Source="/DocomGUI;component/Resources/logo.jpg" />
    </Grid>
</Window>
10
  • 1
    Probably a blanking to remove company name. ;) Commented Jul 24, 2012 at 13:46
  • Exactly right ;-) Sorry about that - And before you come into temptation: no, the filename is correct everywhere ^^ Commented Jul 24, 2012 at 13:47
  • @FlorianPeschka: Also considering casing etc.? Can you get it to work for say, the folder icon? Commented Jul 24, 2012 at 13:49
  • Yes. All other images can be used without problems in the same window. Commented Jul 24, 2012 at 13:53
  • 1
    I solved this problem once by simply restarting visual studio, it's worth a try if everything seems correct otherwise. Commented Jul 24, 2012 at 14:10

2 Answers 2

4

This has happened to me before, and it actually fixed itself simply by restarting visual studio. I'm not really sure why.

Sign up to request clarification or add additional context in comments.

Comments

2

What happens if you declare it in the window.resources like this:

<BitmapImage x:Key="logo" UriSource="/Resources/logo.jpg" />

and use it like this?

<Image Margin="12,12,12,0" Stretch="Fill" Height="48" VerticalAlignment="Top" Source="{StaticResource logo}" />    

I'm suggesting this because I once had a similar problem and this workaround worked out for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.