This seems to be a bit of an infamous error all over the web. So much so that I have been unable to find an answer to my problem as my scenario doesn\'t fit. An exception ge
This article explains in detail what exactly happens: Bitmap and Image constructor dependencies
In short, for a lifetime of an Image
constructed from a stream, the stream must not be destroyed.
So, instead of
using (var strm = new ... ) {
myImage = Image.FromStream(strm);
}
try this
Stream imageStream;
...
imageStream = new ...;
myImage = Image.FromStream(strm);
and close imageStream at the form close or web page close.