When I try to Serialize some images using the BinaryFormatter, I\'ll get a ExternalException - A generic error occurred in GDI+.\" After scratching my head for awhi
Although the Bitmap
class is marked as [Serializable]
, it does not actually support serialisation. The best you can do is serialise the byte[]
containing the raw image data and then re-create it using a MemoryStream
and the Image.FromStream()
method.
I can't explain the inconsistent behaviour you're experiencing; for me, it fails unconditionally (although I first discovered this when trying to marshal images between different app domains, rather than manually serialising them).