-2
using (MemoryStream mem = new MemoryStream(data))
{
 System.Drawing.Image imgPhoto = System.Drawing.Image.FromStream(mem);
}

This is the code that I am using . The problem is that as soon as that debugger processes this line :

System.Drawing.Image imgPhoto = System.Drawing.Image.FromStream(mem);

It gives an error parameter invalid . So after I checked the parameters for "mem" while it is debugging , I noticed that the position parameter is setting to zero every time .

I noticed one more thing here : when I am receiving images from sources beginning with url : external.xx.fbcdnsafe ... The position parameter is not setting to some value and always setting to zero and that's the time when I am getting the error . Please refer the screen shot .

But for images beginning with URL : scontent.xx.fbcdn.n... The position parameter is setting some value . Please refer the screenshot .

For external Sources : url starting with external.xx.fbcdn.net For scontent Sources : url starting with scontent.xx.fbcdn.net

Mohit S
  • 13,723
  • 6
  • 34
  • 69
bijitm
  • 59
  • 4

1 Answers1

0

You receive a "parameter invalid" exception when the format of the stream is not recognizable as an image. See

"Parameter not valid" exception loading System.Drawing.Image

Check the contents of the data you are receiving from your scontent.xx.fbcdn.n... URLs. Perhaps they are a 404 error, or some other content, rather than valid image data.

Community
  • 1
  • 1
David Jeske
  • 2,306
  • 24
  • 29
  • Thanks ... I guess the images from external.xx.fbcdn are not valid images or the format is incorrect so this may create a problem in parsing that image ... – bijitm Apr 14 '17 at 07:58