System.ArgumentException: Parameter is not valid

前端 未结 3 637
囚心锁ツ
囚心锁ツ 2020-12-20 14:43

I have a page that sends html5 canvas data, encoded as a base64 bmp image (using this algorithm http://devpro.it/code/216.html) to a serverside process that converts it into

3条回答
  •  Happy的楠姐
    2020-12-20 15:20

    The posted code seems correct. I have tested it and it works fine.

    The exception "System.ArgumentException: Parameter is not valid." without any other hint (especially not the name of the parameter) is a wrapper for GDI+ (the underlying technology behind .NET Image class) standard InvalidParameter error, which does not tell use exactly what parameter is invalid.

    So, following the FromStream code with .NET Reflector, we can see that the parameters used in GDI+ calls are essentially ... the input stream.

    So my guess is the input stream you provide is sometimes invalid as an image? You should save the failing input streams (using File.SaveAllBytes(sf) for example) for further investigation.

提交回复
热议问题