当前位置:编程学习 > C#/ASP.NET >>

XML序列化异常,在线等

调用一个wsdl,用vs自动生成了本地代码,对其中的类赋值后,发现类中decimal类型无法序列化,不会出现在序列化后的xml文件中,vs自动生成代码如下:

    
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.17929")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://chemchina.com/xi/ordsys")]
    public partial class XXXX: object, System.ComponentModel.INotifyPropertyChanged {        
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=14)]
        public decimal TARGET_QTY {
            get {
                return this.tARGET_QTYField;
            }
            set {
                this.tARGET_QTYField = value;
                this.RaisePropertyChanged("TARGET_QTY");
            }
        }
}


序列化代码:
                
XmlSerializer serializer = new XmlSerializer(typeof(XXXX));
                TextWriter writer = new StreamWriter(@"D:\text.xml");
                serializer.Serialize(writer, OrderData);
                writer.Close();

调试发现OrderData中的TARGET_QTY的属性是有值得,但是序列化后文件中没有,string类型的就不会有问题 --------------------编程问答-------------------- --------------------编程问答-------------------- 你自己使用XmlDocument 自己加载看看能加载上么 --------------------编程问答-------------------- 序列化后xml文件中都没有那个属性 --------------------编程问答-------------------- 自己写个c# winform 用XmlDocument是加载试试啊
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,