反序列化对象时出错 [英] Error deserializing the object

查看:65
本文介绍了反序列化对象时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 WCF 服务.它有以下属性.

I have a WCF service. It has a following attributes.

[DataMember]
public List<uttAppointmentPhoneList> AppointmentPhoneList { get; set; }

public class uttAppointmentPhoneList
{
    string _PhoneType;
    Int32 _PhoneNumber;
    bool _IsDelete;

    [DataMember]
    public string PhoneType
    {
        get { return _PhoneType; }
        set { _PhoneType = value; }
    }

    [DataMember]
    public Int32 PhoneNumber
    {
        get { return _PhoneNumber; }
        set { _PhoneNumber = value; }
    }

    [DataMember]
    public bool IsDelete
    {
        get { return _IsDelete; }
        set { _IsDelete = value; }
    }

}

但是当我发送请求时出现以下错误.

But I get the following error when I send a request.

格式化程序在尝试反序列化消息时抛出异常:尝试反序列化参数时出错.InnerException 消息是反序列化 MarshfieldClinic.Denbigh.AppointmentService.Sync.DataContracts.mydayapp 类型的对象时出错.值3456787463"无法解析为Int32"类型.请参阅 InnerException 了解更多详情.

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter. The InnerException message was 'There was an error deserializing the object of type MarshfieldClinic.Denbigh.AppointmentService.Sync.DataContracts.mydayapp. The value '3456787463' cannot be parsed as the type 'Int32'.'. Please see InnerException for more details.

任何想法为什么会发生这种情况?谢谢

Any Ideas why this is happening? Thanks

推荐答案

Int32 电话号码

这是完全错误的.
电话号码是一个字符串,而不是一个数字.

That's totally wrong.
A phone number is a string, not a number.

发生此特定错误是因为大多数电话号码不适合 32 位.
但是,您需要使用字符串.

This specific error is happening because most phone numbers will not fit in 32 bits.
However, you need to use a string.

这篇关于反序列化对象时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆