C# - System.FormatException: Input string was not in a correct format.

Answered C# - System.FormatException: Input string was not in a correct format.

  • Tuesday, May 04, 2010 7:50 AM
     
     

    Several years ago I had some software developed in C#. 

    We have several people using this software in many locations.  Today, the software began to display the following message when you try to change the COM Port settings in the software:

    System.FormatException: Input string was not in a correct format.

    The only thing that we can put it down to is a windows update, as the software has worked for years on these PC's, and only the ones that have had a windows update appear to have this problem.

    Has anyone else had this experience? (Software tried and tested for several years - then all of a sudden this error appears - System.FormatException: Input string was not in a correct format.)

    If so, does anyone have a solution for it?

    Thanks in advance, Steve.

All Replies

  • Tuesday, May 04, 2010 12:08 PM
     
     Answered
    Checkout DateTime Format of the system
  • Monday, May 10, 2010 2:46 AM
    Moderator
     
     Answered

    Hi,

    It's hard for us to see the problem. I found this in a thread :this exception will be thrown when you convert a null value to a meaningful value:

    You can't convert a null value to a meaningful value through Convert.  Your best option is to check for null first and then assign a value of 0 (or whatever) to the result (whereever Convert was sending its results too).

    http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/fc6b2e87-3d54-4608-b6bf-4723613333bf

    Please check out if the exception is thrown from the snippet that converts value.

    Harry


    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.