none
System.ArgumentNullException: Value cannot be null.

    Question


  • We have a project “A” which is a C# DLL project. This DLL is consumed in a windows forms C# project.
    Currently we are facing problem of “Null Exception” in the below scenario.
    An windows application (project X ) is written including Project “A” 1.1 version DLL. This works fine with Project “A” 1.1 version DLL.

    Project “A” version 1.0 DLL is installed on a Machine X, and the above project X executable and Project”A” 1.1 version DLL is copied into the Installation directory of Project”A” version 1.0 on machine X..
    While running the project it is expected to return “version mismatch or File not found error” but below error message is thrown.

    System.ArgumentNullException: Value cannot be null.
    Parameter name: format
     at System.String.Format(IFormatProvider provider, String format, Object[] args)
     at ProjectA.ctor(IntPtr windowHandle)
       at TestDT.frmScan.frmScan_Load(Object sender, EventArgs e)
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


    I know that the user is not suppose to do this, but still let me know why Null Exception is thrown instead of Version mismatch or file not found exception.


    sarvanan
    • Moved by YiChun Chen Monday, August 09, 2010 11:33 AM C# issue (From:.NET Framework Setup)
    Friday, August 06, 2010 9:38 AM

Answers

  • Hi,

    I have resolved the Issue, it was problem with a string variable in the resource file which was not present.

    Here I would like to ask or highlight something that I noticed. My Project is in VS2005. Here there is no particular resource variable to which we were pointing in the Code, the surprise here is when the project was built using VS2005 no error was thrown. But when I converted the same project to VS2008 there was an compilation error for referring to an non-existence resource variable. It looks like VS2005 during compilation If no resource variable is present it creates one with NULL value ? Please let me know the reason behind this. :) 

    Any way thanks for your kind response. This forum is very much useful to me all through my career.


    sarvanan
    • Proposed as answer by s3rvy Tuesday, August 10, 2010 7:31 PM
    • Marked as answer by Alan_chenModerator Wednesday, August 11, 2010 3:04 AM
    Tuesday, August 10, 2010 3:27 AM

All replies

  • Hi Sarwanan,

     

    I think u getting this exception is because of you try to do String.Format(format) which format is a null string. You may try to debug and find out why format getting null value.

     

    best regards

    cchitsiang

    Friday, August 06, 2010 8:03 PM
  • Hi Sarwanan,

    I am moving this thread from Base ".Net Framework Setup" forum to the "Visual C# General" forum, since the issue is related to C#. There are more C# experts in the "Visual C# General" forum.

    Thanks!

    Best regards,
    Yichun Chen
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, August 09, 2010 11:32 AM
  • Hi Sarwanan,

    To give a specific answer, I would need to see your code.  However, in looking at the stack trace, my best guess is that there is a problem with the "object[] args" parameter in a string.Format() call.  Most likely you have not provided enough elements to correspond to the number of tokens specified in the "string format" parameter.  However, it might also be true that one of the elements in the array is null.

    Monday, August 09, 2010 1:38 PM
  • Hi,

    I have resolved the Issue, it was problem with a string variable in the resource file which was not present.

    Here I would like to ask or highlight something that I noticed. My Project is in VS2005. Here there is no particular resource variable to which we were pointing in the Code, the surprise here is when the project was built using VS2005 no error was thrown. But when I converted the same project to VS2008 there was an compilation error for referring to an non-existence resource variable. It looks like VS2005 during compilation If no resource variable is present it creates one with NULL value ? Please let me know the reason behind this. :) 

    Any way thanks for your kind response. This forum is very much useful to me all through my career.


    sarvanan
    • Proposed as answer by s3rvy Tuesday, August 10, 2010 7:31 PM
    • Marked as answer by Alan_chenModerator Wednesday, August 11, 2010 3:04 AM
    Tuesday, August 10, 2010 3:27 AM