Argument Exception Unhandled when using Image.FromStream()
<p>I am trying to save an image from a stream and I get Argument Exception Unhandled error on the Image.FromStream() line. I've searched a lot and tried many solutions offered since it seems to be a common problem but nothing is working. </p>

<p>The error:System.ArgumentException was unhandled; Message=Parameter is not valid; Source=System.Drawing</p>

<pre><code>MemoryStream mm = new MemoryStream(imageByte);
Console.Write(imageByte);
Image image = System.Drawing.Image.FromStream(mm); //error occurs here
image.Save("Received.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);   
</code></pre>

<p>A strange thing is that if I run the same code on a 32 bit system, the error it gives is "A generic error occurred in GDI+". </p>

<p>A bit more about 'imageBytes':
I am transmitting an image by converting it into a hex string. The data I sent is by wireless means (Zigbee) and upon receiving it, I write it to a text file from which I use this to get imageBytes:</p>

<pre><code>int NumberChars = hexString.Length;
byte[] imageByte = new byte[NumberChars / 2];

for (int i = 0; i &lt; NumberChars; i += 2)
{
     imageByte[i/2] = Convert.ToByte(hexString.Substring(i, 2), 16);
}
</code></pre>
