[Mono-list] System.Drawing.Image serialization

Sebastien Pouliot sebastien.pouliot at gmail.com
Fri Jan 19 08:42:55 EST 2007


On Fri, 2007-01-19 at 11:24 +0200, Oleg Deribas wrote:
> Hello,
> 
> I'm trying to use System.Drawing.Image in web service and have the
> following exception:
> 
> System.InvalidOperationException:
> 	There was an error reflecting field 'TechStatusImage'.
> ---> System.InvalidOperationException:
> 	There was an error reflecting type 'System.Drawing.Image'.
> ---> System.InvalidOperationException:
> 	There was an error reflecting field 'Palette'.
> ---> System.InvalidOperationException:
> 	There was an error reflecting type 'System.Drawing.Imaging.ColorPalette'.
> 	---> System.InvalidOperationException:
> System.Drawing.Imaging.ColorPalette cannot be serialized because it does
> not have a default public constructor
> 
> And I noticed that Microsoft's ASP.NET doesn't even try to reflect
> Palette field and produces such output in the example response:
> 
> <MyImage>
>     <Tag />
>     <Palette xsi:nil="true" />
> </MyImage>
> 
> Is it a bug in mono?

Looks like it, if MS can serialize an Image so should Mono. Please fill
a bug into bugzilla for this.

But note that it's very likely that Mono and MS serialized images won't
interoperate (different internal representation) and it's also a
wasteful way to send the image. 

You should look at saving the image into a stream (e.g. as a PNG image),
serialized the stream, then re-created the image from the stream on the
other end.

-- 
Sebastien Pouliot  <sebastien at ximian.com>
Blog: http://pages.infinit.net/ctech/



More information about the Mono-list mailing list