3

My class uses an image as Property (public Image myImage). When this class is serialized (XamlWriter) it works fine, reading it back gives an exception:

'No matching constructor found on type 'System.Drawing.Bitmap'. You can use the Arguments or FactoryMethod directives to construct this type.' Line number '5' and line position '8'.

Obviously there is a constructor missing for Bitmap with ColorPalette as argument:

<sd:Bitmap>
  <sd:Bitmap.Palette>
    <sdi:ColorPalette /> 
  </sd:Bitmap.Palette>
</sd:Bitmap>

I understand that I can specify a factory method creating the bitmap somehow. I also found some articles about directives for this such as http://www.wpftutorial.net/XAML2009.html

However, I am not an expert in Xaml and do not understand how and where to define / declare the method on my attribute. Unfortunately i do also not find an example for this.

I expect some like

[FactoryMethod("XYZ")]
public Image myImage ....

but actually have found nothing. Any idea / example you know?

Horst Walter
  • 13,663
  • 32
  • 126
  • 228
  • Same problem i too have. If i found solution i will tell you. – Code0987 Jan 29 '11 at 13:00
  • 1
    See [http://stackoverflow.com/questions/14346244/xamlparseexception-in-app-xaml-resource-strings][1] [1]: http://stackoverflow.com/questions/14346244/xamlparseexception-in-app-xaml-resource-strings – Michel Keijzers Jan 15 '13 at 21:17

0 Answers0