I have a WPF application where I added the images as resources to the project (not from project settings, like how the 2nd answer does it here), so they are under a folder. I use them like this in xaml:
<Image Width="32" Height="32" Source="/Images/Effect.png" />
When I run the program manually, either from visual studio or explorer, the images show up fine, no error, etc.
But when I run it from another application via reflection, it prints these exceptions inside visual studio:
System.Windows.Data Error: 6 : 'TargetDefaultValueConverter' converter failed to convert value '/Images/Effect.png' (type 'String'); fallback value will be used, if available. BindingExpression:Path=EffectIcon; DataItem='Node' (HashCode=34743541); target element is 'Image' (Name=''); target property is 'Source' (type 'ImageSource') IOException:'System.IO.IOException: Cannot locate resource 'images/effect.png'.
In the end, the application starts up fine but all images are missing.
Any idea on how to fix this?
Should I be binding the images in a different way?
The problem is probably that the images will be searched in the assembly from where you instantiated your modules via reflection. One possibility to resolve this problem is, that you assign the full path to the images, including the assembly name. Something like:
Try this: "pack://application:,,,/AssemblyName;/components/image/effect.png"