input string was not in a correct format in Class

Rinaldo 396 Reputation points
2021-11-26T08:56:41.677+00:00

I know this error, try to parse string into int for example.

I've made a .CS class file against Paste Special in the edit menu of VS 2017. On dat moment no problem is I import the XML file where I imported the class file from. If I take another XML file it fail with the error input string was not in a correct format. I do nothing know about serilisation but I suspect the following lines:

    [System.SerializableAttribute()]

    [System.ComponentModel.DesignerCategoryAttribute("code")]

    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true,
        Namespace = "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2")]

    [System.Xml.Serialization.XmlRootAttribute(Namespace = "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2",
        IsNullable = false)]

errors

bij System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
bij System.Number.ParseUInt32(String value, NumberStyles options, NumberFormatInfo numfmt)
bij Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderInvoice.Read14_Item(Boolean isNullable, Boolean checkType)
bij Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderInvoice.Read15_AccountingSupplierPartyParty(Boolean isNullable, Boolean checkType)
bij Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderInvoice.Read16_AccountingSupplierParty(Boolean isNullable, Boolean checkType)
bij Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderInvoice.Read45_Invoice(Boolean isNullable, Boolean checkType)
bij Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderInvoice.Read46_Invoice()

Somebody knows this serialisation error?
Greetings Rinaldo

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,278 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. P a u l 10,406 Reputation points
    2021-11-26T09:33:17.767+00:00

    If the issue is that you have two XML files and you've generated a class from the first, but the second doesn't deserialise into it, then I'd recommend generating a class from your second file too & then put both classes into something like this so you can see the differences more clearly:
    https://www.diffchecker.com