Я думал, что мне никогда не придется задавать этот вопрос, но, видимо, что-то не так с сериализацией или моим использованием.
Я есть класс, который мне нужно сериализовать:
Код: Выделить всё
[Serializable]
public class Device : ISerializable, IDisposable
{
public delegate void ListChangedEventHandler(object sender, ListChangedEventArgs e);
public string Name { get; set; }
public string Description { get; set; }
public string IPAddress { get; set; }
[Browsable(false)]
public ThreadSafeBindingList Items { get; set; }
[Browsable(false)]
public MibEntity AssociatedMibEntity { get; set; }
//methods etc.
}
ThreadSafeBindingList наследуется от System.ComponentModel.BindingList
MibEntity — это класс библиотеки SharpSNMP (https://sharpsnmp.com/)
Проблема:
Когда я пытаюсь десериализовать объект, MibEntity всегда имеет значение null. С другими свойствами все в порядке.
Класс MibEntity находится во внешней dll, на которую я ссылаюсь в проекте, где находится класс Device.
Это его содержимое:
Код: Выделить всё
[Serializable]
public class MibEntity
{
public MibEntity()
{
Children = new List();
}
[Browsable(false)]
public List Children { get; set; }
[Browsable(true)]
[Category("General")]
public string OID { get; set; }
private string _name;
[Browsable(true)]
[Category("General")]
public string Name
{
get { return _name; }
set { _name = value; }
}
[Browsable(true)]
public string Description { get; set; }
[Browsable(false)]
public int Value { get; set; }
[Browsable(true)]
public AccessType AccessType { get; set; } //this is enum from SharpSNMP library
[Browsable(true)]
public Status Status { get; set; } //this is enum from same assembly as this class
[Browsable(true)]
public string Syntax { get; set; }
[Browsable(true)]
public bool IsTableEntry { get; set; }
[Browsable(true)]
public IDefinition IDefinition { get; set; } //this is interface from SharpSNMP library
}
Спасибо за помощь!
Подробнее здесь: https://stackoverflow.com/questions/183 ... -trouble-c