tags:

views:

194

answers:

5

hey guys, i'm getting an exception on the following

inner exception: {"Value cannot be null.\r\nParameter name: String"}

Which reads like a simple error message, but none of the values (image, fileName) are null. How can i find out where this null String 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 full error log

#

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

+3  A: 

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

Perhaps the static constructor is referencing a static field that has not yet been initialized. If you are having trouble debugging this, post the code of the class including the static constructor and any field initializers.

Joe
Rats, beaten by 47 seconds ;)
Jon Skeet
"Rats, beaten by 47 seconds" - hey, don't be greedy :)
Joe
+1  A: 

The error is occuring in the static constructor of the RipHelper class.

James Curran
Or a static variable initializer. Either way it's at line 23 :)
Jon Skeet
"Or a static variable initializer" - no the trace says RipHelper..cctor, which is the static constructor
Joe
+1  A: 

RipHelper line 23 is trying to convert a null string into an integer, and failing. This is probably in a constructor or static initializer. Do you have access to the RipHelper source code?

Steven A. Lowe
+1  A: 

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

Coderer
A: 

Thanks guys. Lesson learnt 'Pay more attention to the error log'. Here the culprit

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

PreviewImageHeight was misspelt in the config.

frosty