C# DefaultValueAttribute与XML序列化冲突

C# DefaultValueAttribute与XML序列化冲突,c#,serialization,C#,Serialization,我试图让用户在序列化对象之前修改它。对于对象的编辑,我使用PropertyGrid,因此我必须向其中添加属性,如下所示: [CategoryAttribute("General"), DefaultValueAttribute(true), DescriptionAttribute("Calculate MD5")] public bool ComputeMd5 { get; set; } 当我尝试序列化此对象时,属性消失,当我删除所有属性时,序列化将顺利进行。

我试图让用户在序列化对象之前修改它。对于对象的编辑,我使用PropertyGrid,因此我必须向其中添加属性,如下所示:

    [CategoryAttribute("General"),
    DefaultValueAttribute(true),
    DescriptionAttribute("Calculate MD5")]
    public bool ComputeMd5 { get; set; }
当我尝试序列化此对象时,属性消失,当我删除所有属性时,序列化将顺利进行。知道为什么吗

我已经弄明白了。 显然,当您设置Default属性且实际值等于Default时,序列化程序不会将其保存到文件中