Tôi serializing một lớp học và tôi nhận được ngoại lệ sau đây:XMLSERIALIZE Exception
Bạn phải thực hiện một accessor mặc định trên System.Configuration.SettingsPropertyCollection vì nó thừa hưởng từ ICollection.
khi dòng sau được thực hiện:
XmlSerializer xs = new XmlSerializer(typeof(CustomConfiguration));
Bất kỳ sự giúp đỡ?
public class CustomConfiguration : ConfigurationObjectBase
{
public CustomConfiguration() { //DO NOTHING. }
[User]
public uint Version
{ get { return ((uint)(this["Version"])); }
set { this["Version"] = value; }
}
}
ConfigurationObjectBase có nguồn gốc từ System.configuration.ApplicationSettingsBase.
Bạn có thể hiển thị bất kỳ phiên bản nào của lớp 'CustomConfiguration' (đặc biệt là thừa kế, v.v.) không? –
lớp công khai CustomConfiguration: ConfigurationObjectBase { Public CustomConfiguration() { // KHÔNG GHI CHÚ. } /// /// Version /// [User] công uint Version { được { return ((uint) (điều này [ "Version"])); } đặt { ["Phiên bản"] = giá trị này; } } } Cấu hìnhObjectBase có nguồn gốc từ System.configuration.ApplicationSettingsBase –
siva
Tôi có thể hỏi tại sao bạn vẫn đang cố gắng sắp xếp thứ tự này không? Có vẻ hơi lạ. –