[c#] A generic error occurred in GDI+, JPEG Image to MemoryStream

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.