How do I construct a pack URI to an image that is in a resource file?
I have an assembly called MyAssembly.Resources.dll
, it has a folder called Images, then in there is a resource file called Assets.resx. This resource file contains my image (called MyImage.png). The line of code I have is:
uri = new Uri("pack://application:,,,/MyAssembly.Resources,Culture=neutral,PublicKeyToken=null;component/Images/Assets/MyImage.png");
However when I try to supply this URI to the constructor of a new BitmapImage I get an IOException with the message
Cannot locate resource 'images/assets/myimage.png'.
Note that I have other loose images in the same assembly which I can retrieve fine using a pack URI, those images have their build action set to Resource but they are not embedded in a resx file. Should I be including the name of the resx file in the path?
(I am looking to embed images in resx files so that I can leverage UI culture settings to retrieve the right image (the image contains text)).