1

In solution explorer to my Class Library I added folder "Resources" with few images in it (image.png). I set build action of each image.png as "Resource".

Now inside this dll I want to return Bitmap image from those resources. But I'm getting error that file is not found.

new BitmapImage(new Uri("pack://application:,,,/Resources/de_image.png"))

This is error:

Cannot locate resource 'resources/de_image.png'.

Any idea how to fix it?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Hooch
  • 28,817
  • 29
  • 102
  • 161
  • Why are you trying to access through a URI? – John Saunders Dec 30 '14 at 00:31
  • @JohnSaunders How to access it in other way? – Hooch Dec 30 '14 at 00:39
  • Same as any other resource: http://msdn.microsoft.com/en-us/library/xc4235zt.aspx. I've never heard of resources being accessed through a URI. What made you think that would work? – John Saunders Dec 30 '14 at 00:42
  • ... which would be due to the fact that I don't use WPF: http://msdn.microsoft.com/en-us/library/aa970069.aspx – John Saunders Dec 30 '14 at 00:43
  • Possible duplicate of [How can I access a resource image within XAML in a user control library?](http://stackoverflow.com/questions/21167561/how-can-i-access-a-resource-image-within-xaml-in-a-user-control-library) – Athafoud Apr 14 '16 at 08:09

1 Answers1

1

You can code like this:

new BitmapImage(new Uri("pack://application:,,,/[AssemblyName];component/[Path]/[To]/[Image]"))

Hans Huang
  • 23
  • 5