Exception with System.Drawing.Image

Hi guys I am getting an exception from the following

inner exception: {"The value cannot be empty. \ r \ nParameter: String"}

Which reads as a simple error message, but none of the values ​​(image, fileName) matter. How do I know where this line is?

RipHelper.UploadImage(image, fileName);

      

which calls

public static void UploadImage(System.Drawing.Image image, string fileName)
        {
// this line is never reached
         }

      

Here is the complete error log

#

System.ArgumentNullException: The value cannot be null. Parameter name: String in System.Number.StringToNumber (String str, NumberStyles, NumberBuffer & number, NumberFormatInfo info parameters, Boolean parseDecimal) in System.Number.ParseInt32 (String s, NumberStyles style, NumberFormatInfo info) in System.Int32.Parse ( String s) in Helpers.RipHelper..cctor () in C: \ Helpers \ RipHelper.cs: line 23 --- End of internal check of exception stack --- in Helpers.RipHelper.UploadImage (HttpPostedFile uploadFile, String fileName) in Helpers .UploadHelper.UploadImage (HttpContext context) at C: \ Helpers \ UploadHelper.cs: line 79

+1


source to share


5 answers


The exception is the static constructor of the Helpers.RipHelper class on line 23 of RipHelper.cs. This line calls Int32.Parse, passing in a null value.



Perhaps the static constructor refers to a static field that hasn't been initialized yet. If you are having trouble debugging this, please post the class code, including the static constructor and any field initializers.

+3


source


The error occurs in the static constructor of the RipHelper class.



+1


source


Line 23 RipHelper tries to convert a null string to an integer and fails. It's probably in a constructor or static initializer. Do you have access to the RipHelper source code?

+1


source


.cctor () makes it sound like you have a problem in the constructor of your RipHelper class. Can you walk through the code in debug mode and see which line is actually throwing the exception?

+1


source


Thanks guys. Lesson Learned "Pay more attention to the error log". Here is the culprit

private static readonly int previewImageHeight = int.Parse(ConfigurationManager.AppSettings["PreviewImageHeight"]);

      

PreviewImageHeight was misconfigured.

0


source







All Articles