Serialization does not use culture specific settings while serializing double value to XML.
-
Hi, I had to do class which stored some information which were double values, and finally the class contents where serialized to XML. When I was reading the contents back to system from XML using XMLDocument, I got an error message which was saying that the input string was not in correct format. I used some time to figure out that the reason was the culture setting of my computer. There input language was English (US) - Finnish, and the regional settings were Finnish. When the XML was serialized to file, the separator in double value was '.' instead of ','. then when I was reading the value, the Double.Parse method expected finnish separator ',' instead of english '.'. Dont know that is there error in code which initializes the serializer, or is this bug. Of cource I expected the serializer to write the double value using culture specific separator. Mika K
-
Hi, I had to do class which stored some information which were double values, and finally the class contents where serialized to XML. When I was reading the contents back to system from XML using XMLDocument, I got an error message which was saying that the input string was not in correct format. I used some time to figure out that the reason was the culture setting of my computer. There input language was English (US) - Finnish, and the regional settings were Finnish. When the XML was serialized to file, the separator in double value was '.' instead of ','. then when I was reading the value, the Double.Parse method expected finnish separator ',' instead of english '.'. Dont know that is there error in code which initializes the serializer, or is this bug. Of cource I expected the serializer to write the double value using culture specific separator. Mika K
Hi, I don't think its a bug. Probably a flaw that the default behavior cannot be overridden. It makes absoluetly sense that by default the neutral culture is uesd. Otherwise two computers with different cultural settings couldn't communicate via Remoting with each other. Robert
-
Hi, I don't think its a bug. Probably a flaw that the default behavior cannot be overridden. It makes absoluetly sense that by default the neutral culture is uesd. Otherwise two computers with different cultural settings couldn't communicate via Remoting with each other. Robert
-
Hi, I had to do class which stored some information which were double values, and finally the class contents where serialized to XML. When I was reading the contents back to system from XML using XMLDocument, I got an error message which was saying that the input string was not in correct format. I used some time to figure out that the reason was the culture setting of my computer. There input language was English (US) - Finnish, and the regional settings were Finnish. When the XML was serialized to file, the separator in double value was '.' instead of ','. then when I was reading the value, the Double.Parse method expected finnish separator ',' instead of english '.'. Dont know that is there error in code which initializes the serializer, or is this bug. Of cource I expected the serializer to write the double value using culture specific separator. Mika K
ToString uses the current thread's CultureInfo by default. Always overload ToString(CultureInfo.InvariantCulture) for persisting to file. Similarly for parsing. For the UI it's ok to use the current culture info.
Wout