I have a WPF .Net 4.0 application that has been running just fine under WinPE 4.0, until recently. I added the code shown below, and it broke the app when running it under WinPE 4.0. Note, the app still runs fine under Windows 7 x64 and Windows 2012.
[ValueConversion(typeof(string), typeof(bool))]
public class HeaderToImageConverter : IValueConverter
{
public static HeaderToImageConverter Instance =
new HeaderToImageConverter();
public object Convert(object value, Type targetType,
object parameter, CultureInfo culture)
{
if ((value as string).Contains("corp.com"))
{
Uri uri = new Uri
("pack://application:,,,/Images/DeployWiz_Network.png");
BitmapImage source = new BitmapImage();
source.BeginInit();
source.UriSource = uri;
source.DecodePixelHeight = 40;
source.EndInit();
return source;
}
else
{
Uri uri = new Uri
("pack://application:,,,/Images/ou2.png");
BitmapImage source = new BitmapImage();
source.BeginInit();
source.UriSource = uri;
source.DecodePixelHeight = 20;
source.EndInit();
return source;
}
}
public object ConvertBack(object value, Type targetType,
object parameter, CultureInfo culture)
{
throw new NotSupportedException("Cannot convert back");
}
}
This code allows me to use a different image in my Treeview control based on the contents of the treeview item.
When running this under WinPE, I get the following exception:
So, I put the missing .DLL in the same folder as my .exe, and then I get this exception:
Is there something funky about the .dll that doesn't cause it to work in WinPE? Is there any other class I can use besides BitmapImage in WPF to accomplish my goals and avoid this .dll? Is BitmapImage even the class that needs this .dll? I assume it is because it's the only new code I've added that breaks my app.