none
c# - Deserializing XML Value was either too large or too small for an unsigned byte-getting error?

    Question

  • Hi,

    while doing c# - Deserializing XML file,we are getting error like "Value was either too large or too small for an unsigned byte".

    can you please help, how to resolve this issue?

    Regards,

    Sanath


    sanath.avula@gmail.com

    Friday, April 7, 2017 4:48 AM

Answers

  • while doing c# - Deserializing XML file,we are getting error like "Value was either too large or too small for an unsigned byte".

    can you please help, how to resolve this issue?

    If possible, use a larger data type for your members and variables, since a byte can only hold values between 0 and 255. For example, use uint or int.

    Sunday, April 9, 2017 8:11 AM
  • Hi AvulaSanath,

    Continuing from Viorel_'s answer, You can also refer this.

    short.MaxValue:  32767
    short.MinValue: -32768
    ushort.MaxValue: 65535
    ushort.MinValue: 0
    int.MaxValue:    2,147,483,647
    int.MinValue:   -2,147,483,648
    uint.MaxValue:   4,294,967,295
    uint.MinValue:   0
    long.MaxValue:   9,223,372,036,854,775,807
    long.MinValue:  -9,223,372,036,854,775,808
    ulong.MaxValue:  18,446,744,073,709,551,615


    Thanks,
    Sabah Shariq

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered "Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]

    Sunday, April 9, 2017 3:28 PM
    Moderator

All replies

  • Need More information atleast the class structure.

    --------------------------------------------------------

    Surender Singh Bhadauria

    My Blog

     

    Friday, April 7, 2017 4:54 AM
  • Looks like the value in the XML is not in defined range for the object you are deserializing into .

    Mark Answered, if it solves your question and Vote if you found it helpful.
    Rohit Arora

    Friday, April 7, 2017 10:04 AM
  • while doing c# - Deserializing XML file,we are getting error like "Value was either too large or too small for an unsigned byte".

    can you please help, how to resolve this issue?

    If possible, use a larger data type for your members and variables, since a byte can only hold values between 0 and 255. For example, use uint or int.

    Sunday, April 9, 2017 8:11 AM
  • Hi AvulaSanath,

    Continuing from Viorel_'s answer, You can also refer this.

    short.MaxValue:  32767
    short.MinValue: -32768
    ushort.MaxValue: 65535
    ushort.MinValue: 0
    int.MaxValue:    2,147,483,647
    int.MinValue:   -2,147,483,648
    uint.MaxValue:   4,294,967,295
    uint.MinValue:   0
    long.MaxValue:   9,223,372,036,854,775,807
    long.MinValue:  -9,223,372,036,854,775,808
    ulong.MaxValue:  18,446,744,073,709,551,615


    Thanks,
    Sabah Shariq

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered "Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]

    Sunday, April 9, 2017 3:28 PM
    Moderator
  • Hi AvulaSanath,

    If your issue is solved please Mark as answer or Vote as helpful post to the appropriate answer so that it will help other members to find solution if they faces similar issue.

    Your understanding and cooperation will be grateful.

    Thanks,
    Sabah Shariq

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered "Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]

    Friday, May 12, 2017 1:08 PM
    Moderator