Jump to content

FormatException: Input string was not in a correct format


Recommended Posts


I'm trying to run the sample scenes for the SRWorks v9.3.0 but I keep getting this error message:

FormatException: Input string was not in a correct format.
System.Number.ParseSingle (System.String value, System.Globalization.NumberStyles options, System.Globalization.NumberFormatInfo numfmt) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Single.Parse (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Single.Parse (System.String s) (at <437ba245d8404784b9fbab9b439ac908>:0)
Vive.Plugin.SR.ViveSR_DualCameraCalibrationTool.LoadParamsValue (System.Int32 angle_index, System.Single default_value) (at Assets/ViveSR/Scripts/ViveSR_DualCameraCalibrationTool.cs:196)
Vive.Plugin.SR.ViveSR_DualCameraCalibrationTool.LoadDeviceParameter () (at Assets/ViveSR/Scripts/ViveSR_DualCameraCalibrationTool.cs:136)
Vive.Plugin.SR.ViveSR_DualCameraRig.Initial () (at Assets/ViveSR/Scripts/ViveSR_DualCameraRig.cs:179)
Vive.Plugin.SR.ViveSR.UpdateWhileWorking () (at Assets/ViveSR/Scripts/ViveSR.cs:328)
Vive.Plugin.SR.ViveSR.Update () (at Assets/ViveSR/Scripts/ViveSR.cs:175)

It looks like there is something wrong when trying to read the parameters in the calibration file.

@Daniel_Y, @reneeclchen

Link to comment
Share on other sites

  • 2 weeks later...

Hi @JerOhm,

In SRWorks v0.9.3.0, we changed the format of this file: C:\Users\(USER NAME)\AppData\LocalLow\HTC Corporation\SR_Config\calibration_params.bin.

You may have an old .bin file, and therefore the old format, from an old version of SRWorks. Kindly delete the file. SRWorks will regenerate it in the format that can be correctly parsed.

  • Like 1
Link to comment
Share on other sites

Hi @reneeclchen,

I tried your solution and it works for the first execution after deleting the file because there is no calibration file to read. However, I still get the same error the following executions. For some reason, the format of the new calibration file still cannot be parsed. Any ideas why?

Link to comment
Share on other sites


It's most likely just how Unity's binaryreader and -writer work in different machines or operation systems. 

Since the calibration tool is an old feature and will be removed in later versions, I suggest these two steps:

(1) Remove the .bin file, and

(2) In ViveSR_DualCameraCalibrationTool.cs, slash out line 159 like this:

//SaveParamValue(relative_angle, absolute_angle);

The .bin file will then not be saved or loaded. It's not used anyway.

  • Thanks 1
Link to comment
Share on other sites

  • 2 years later...

System.FormatException is a type of exception in the .NET framework. It is thrown when an invalid format is encountered while parsing a string representation of a data type. For example, if you try to parse a string that is not a valid integer representation using the int.Parse() method (string to int) , it will throw a System.FormatException. The exception indicates that the string does not conform to the expected format for the type being parsed.

To fix a System.FormatException in your code, you need to handle the exception and provide an appropriate solution based on the scenario


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...