I have a problem with a BitmapImage in wpf. When i create it it gives a filenotfound exception, which says it’s missing the PresentationCore.resources assembly. But i’ve added it to my references list and it still throws the same exception
Uri filename = new Uri(@"D:\barcode_zwart_wit.jpg", UriKind.Absolute);
BitmapImage image = new BitmapImage(filename); //<-- FileNotFound Exception
- The image uri is correct.
- The image isn’t opened somewhere else
- I’ve checked the version of the PresentationCore.resources, no problem there.
- The lines are in the setter of a property, which is first launched in the constructor of a usercontrol.
- Visual Studio 2010, .net v4
Does anyone have any idea what’s the problem? Does PresentationCore.resources have any dependencies i don’t know about?
I’ve solved it by using AppDomain.CurrentDomain.AssemblyResolve. it’s an event which is called if a certain assembly can’t be found.
in constructor:
CurrentDomain_AssemblyResolve: