#1,109 – Accessing a Resource in a Different Assembly
July 8, 2014 Leave a comment
You can use the following URI, in code, to access a resource embedded into the executing assembly.
BitmapImage bmi = new BitmapImage(new Uri("pack://application:,,,/Images/Ted.jpg"));
If you want to access a resource in a different assembly, you use the Uri syntax shown below, adding the assembly name and the word “component”.
BitmapImage bmi = new BitmapImage(new Uri("pack://application:,,,/MyPictures;component/Ted.jpg"));
This assumes that the image Ted.jpg is included in an assembly named MyPictures (e.g. in MyPictures.dll). It also assumes that the Build Action for the image is set to Resource and that this assembly is in the same directory as the executing assembly. If you want the resource assembly to end up in the same output directory as the main assembly, you’ll want to add a reference to it from the main assembly.