0

I am using this to display a gif in my app:

<Image Height="30" Width="30" gif:ImageBehavior.AnimatedSource="pack://application:,,,/OffPo diagnostic tool;component/resources/c1.gif" Grid.Column="1" Margin="394,110,42,22" Grid.Row="1" />

And it throws me this error :

Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.

My resource path is okay, even it shows the image in design time but fails to compile... What's wrong ?

SEMI-FIX

I used the exact path as the source:

C:\Users\nabil\Documents\Visual Studio 2015\Projects\OffPo Diagnostic Tool\OffPo Diagnostic Tool\resources\c1.gif

This fixed the problem but what if I move my application? Then the problem would occur again. Any permanent fix?

THIS IS WHAT I FOUND WHEN I TRIED INNEREXCEPTION

enter image description here

Software Dev
  • 5,368
  • 5
  • 22
  • 45
  • Do we need to worry about the `` part or is it only pseudo-code to define the source of `gif:ImageBehavior`? Same for the `` and ``, I hope that's not your real code? – grek40 Dec 08 '17 at 07:27
  • yeah , it's kindda copied..anyway, how do i fix the error ?? plese read my edit and give me a solution – Software Dev Dec 08 '17 at 07:38
  • Well, I may look at it again when the mentioned problems are fixed (otherwise the answer would be "can't reproduce", because for example `` with lower case G doesn't match `` and giving a different error than yours) Also please describe how exactly is your image configured as resource? – grek40 Dec 08 '17 at 07:46
  • Okey now ?..... – Software Dev Dec 08 '17 at 07:57
  • What if you use a relative path like Source="resources/c1.gif" ? – mm8 Dec 08 '17 at 15:21
  • You should inspect the `InnerException` of that exception in Debugger. You can see the *real* exception reason in that inner exception. I'm pretty sure you have forgotten to set your image file to a `Resource`, so it is not embedded in the application resources. – dymanoid Dec 08 '17 at 15:44
  • if thats the reason then why does it work if i use full file path? – Software Dev Dec 08 '17 at 17:12
  • @dymanoid i added the image in the resources properly, and using `resources\imagename` also gives the same exception ....any help ?? – Software Dev Dec 09 '17 at 14:44
  • Please re-read my post – Software Dev Dec 09 '17 at 15:19

1 Answers1

1

Fixed it myself...Or should i say SO saved my day again ??

Source

All i had to do is, select the image from the Solution explorer>Properties>Build action>changed 'None' to 'Resources'

Software Dev
  • 5,368
  • 5
  • 22
  • 45