0

'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '12' and line position '18'.

<Window x:Class="Gasoline.Style.BaseWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="BaseWindow" Height="300" Width="300" ResizeMode="NoResize" WindowStyle="None" BorderBrush="Black">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="26"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <DockPanel LastChildFill="False" Height="26">
            <DockPanel.Background>
                <ImageBrush ImageSource="/Resources/FrameTitle.png"/>
            </DockPanel.Background>


        </DockPanel>

    </Grid>
</Window>

And the line in cause is:

<ImageBrush ImageSource="/Resources/FrameTitle.png"/>

What am I doing wrong here?
As soon as I give the brush an image source (even through the properties window, which creates a different value), it throws that error when I start up the application.
The designer works fine.

Vercas
  • 8,931
  • 15
  • 66
  • 106
  • do You mark the image property Copy to output directory? – Mate Nov 03 '12 at 23:39
  • @Mate Just tried it, no change. – Vercas Nov 03 '12 at 23:43
  • Try to set the image source in the properties window rather than doing it in xaml. – TMan Nov 03 '12 at 23:45
  • Take a look at the first 2 answers at http://stackoverflow.com/questions/347614/wpf-image-resources - use the assembly's path in the source to have a stronger filename. Otherwise, have you tried using another image (possibly in a different format) to see if it's not your image that is corrupt? – Joe Nov 03 '12 at 23:47

1 Answers1

1

possible solutions / tips:

1 - Every time you get a 'Provide Value threw an exception' exception, try looking at the InnerException to find the root exception.

2 - Make sure your image files are set to 'Resource' in their Build Action. You do not need 'copy to output directory'.

3 - if everything else fails, try using the Pack URI syntax

Federico Berasategui
  • 43,562
  • 11
  • 100
  • 154
  • Ah, the inner exception was a IO exception (file not found), and the path was the problem indeed. Yesterday, when I selected my image in the designer it generated a path that looks like `pack:///,,, etc.`, but today it generates `/Gasoline;component/ etc.`. I didn't even restart Visual Studio, or close the designer window. Just left the laptop on sleep. But the problem was with the URI so I'll accept this answer. Thank you for the information! – Vercas Nov 04 '12 at 09:12