I have a wpf application in which I have to add image resources dynamically. The respective code is as below.
public class ImageNames
{
static string path = @"pack://application:,,,/" + Assembly.GetExecutingAssembly().GetName().Name + ";component/Images/";
public static BitmapImage TickImage = new BitmapImage(new Uri(path + "icon_tick.gif", UriKind.Absolute));
public static BitmapImage CrossImage = new BitmapImage(new Uri(path + "icon_cross.gif", UriKind.Absolute));
public static BitmapImage DeleteImage = new BitmapImage(new Uri(path + "icon_delete.gif", UriKind.Absolute));
}
The images are added in the respective assembly with Build Action = Resource
. But an exception is thrown at runtime while creating the BitmapImage as Provide value on 'System.Windows.Markup.StaticExtension' threw an exception.