Link to home
Start Free TrialLog in
Avatar of directxBOB
directxBOBFlag for Ireland

asked on

'nonNegativeInteger' is an invalid value for the XmlElementAttribute.DataType property. nonNegativeInteger cannot be converted to System.Int32.

I am getting the following error when I try and load my Web Service

'nonNegativeInteger' is an invalid value for the XmlElementAttribute.DataType property. nonNegativeInteger cannot be converted to System.Int32.

        [XmlElement(DataType="nonNegativeInteger", Order=0, ElementName="AmountInEuroCent")]
        public int AmountInEuroCent
        {
            get { return amountInEuroCent; }
            set
            {
                if ((amountInEuroCent != value))
                {
                    amountInEuroCent = value;
                    RaisePropertyChanged("AmountInEuroCent");
                }
            }
        }

The above Property appears to be the issue. I guess I could change it to a string but then that really wouldn't be ideal. As I would then have to do loads of conversions from string to int.

Any ideas?
Avatar of TheAvenger
TheAvenger
Flag of Switzerland image

What is nonNegativeInteger? Is this a class you wrote?
Avatar of directxBOB

ASKER

XML / SOAP Type
Can you try making your property uint instead of int? This is the correspondence of non negative integer.
Now getting:

'nonNegativeInteger' is an invalid value for the XmlElementAttribute.DataType property. nonNegativeInteger cannot be converted to System.UInt32.
ASKER CERTIFIED SOLUTION
Avatar of TheAvenger
TheAvenger
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Cheers, I bounded them to String as a temp solution back when I posted the question. I believe it's got me around the problem but I really wanted to avoid doing Convert.ToInt

But I guess it can't be avoided.
I don't think the overhead will be great. Even if you have it directly mapped, .Net will do the convertion and it won't be faster.