webservice service System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
Xu Li
5
Reputation points
I am currently encountering an issue with a web service. The server-side field MinimumOrderAmount
is of type double
, and in my receiving program, I have defined it as decimal
. When the server sends a value of 9999999999
for MinimumOrderAmount
, my program throws an error with the following message:
Exception thrown passed to this Web service: System.InvalidOperationException: There is an error in XML document (1, 3998). ---> System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderAvailabilityService.Read13_VoucherDiscount(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderAvailabilityService.Read90_RoomRate(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderAvailabilityService.Read141_RoomStay(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderAvailabilityService.Read142_AvailResponseSegment(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderAvailabilityService.Read143_AvailabilityResponse(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderAvailabilityService.Read191_AvailabilityResponse()
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
Theoretically, a double
type should be able to be directly converted to a decimal
type. Why does this conversion fail when the value is 9999999999
, but succeeds when the value is 999999999
(9 digits)?
Sign in to answer