با سلام

من یه وب سرویس با WCF نوشتم که داخل اون از OpenStreet Api استفاده کردم ولی یه جا بهم خطای parameter is not valid میده.

ممنون

اینم کدمه:

        public byte[] GetPlacePhoto(double? lat, double? lng, int? zoomx, string scriptoriumId)
{
var watch = new Stopwatch();
watch.Start();
try
{
#region checkRangeInputs

//if (sizeH == null)
// throw new ArgumentOutOfRangeException("sizeH is NULL!");
//if (sizeW == null)
// throw new ArgumentOutOfRangeException("sizeH is NULL!");
if (lat == null)
throw new ArgumentOutOfRangeException("lat is NULL!");
if (lng == null)
throw new ArgumentOutOfRangeException("lng is NULL!");
if (zoomx == null)
throw new ArgumentOutOfRangeException("zoomx is NULL!");
if (string.IsNullOrEmpty(scriptoriumId))
throw new ArgumentOutOfRangeException("scriptoriumId is NULL!");

//if (sizeH <= 0 || sizeH >= 1600)
// throw new ArgumentOutOfRangeException("sizeH out off range (range between 0,1600)");
//if (sizeW <= 0 || sizeW >= 1600)
// throw new ArgumentOutOfRangeException("sizeW out off range (range between 0,1600)");

#endregion

//string size = sizeH + "x" + sizeW;
string requeststring = "https://www.openstreetmap.org/#map=" + zoomx + "/" + lng + "/" + lat;
WebRequest request = WebRequest.Create(requeststring);
request.ContentType = "application/json; charset=utf-8";
WebResponse response = request.GetResponse();

if (response.ContentType.StartsWith("image", StringComparison.OrdinalIgnoreCase))
{
using (Stream inputStream = response.GetResponseStream())
{
Image imageIn = Image.FromStream(inputStream);
MemoryStream ms = new MemoryStream();
imageIn.Save(ms, ImageFormat.Png);
byte[] imagebyte = ms.ToArray();
string jsonResponse = JsonConvert.SerializeObject(response);

CreateScriptoriumImageLog(jsonResponse, requeststring, scriptoriumId, convert_milisecond_to_hms(watch.ElapsedMillisecond s));
return imagebyte;
}
}
else
{
CreateScriptoriumImageErrorLog("API Can Not Return Photo: ", response.ToString(), requeststring, scriptoriumId, convert_milisecond_to_hms(watch.ElapsedMillisecond s));
throw new FaultException("API Can Not Return Photo: " + response);
}
}
catch (Exception ex)
{
CreateImageExceptionErrorLog("Exception: " + ex, convert_milisecond_to_hms(watch.ElapsedMillisecond s));
throw new FaultException("Exception: " + ex);
return null;

}
finally
{
watch.Stop();
}
}


توی این خطی که نوشتم خطا میده:

Image imageIn = Image.FromStream(inputStream);


ممنون میشم از دوستان کمکم کنند و بگن چکار کنم؟