My application suddenly started failing to convert a string value of format "18.000"
to a decimal or int with the error
System.FormatException: Input string was not in a correct format.
When trying either
decimal.Parse(stringValue);
int.Parse(stringValue);
Even though a couple of days earlier this was working fine. It also worked on my local machine but not on the publishing server.
It turns out I could resolve this by passing in CultureInfo.InvariantCulture
like this:
decimal.Parse(aod.PnPQuantity, CultureInfo.InvariantCulture)
But when I check the server's localisation settings, it definitely uses a .
as a decimal seperator:
My question is, how is this possible? Is there some other setting I need to check, and is this something that could have changed on its own or has someone been messing with my settings?
Will passing in InvariantCulture
as I have prevent this from happening in the future, or do I need to take further precautions?