我有一个类的以下 C# 代码,我创建了一个我试图在 MessageQueue 中发送的对象,它不断给我 InvalidOperationException “生成 XML 文档时出错”,我无法弄清楚如何摆脱. 我究竟做错了什么?
[Serializable()]
public class InMessage : ISerializable
{
public bool IsSubscription;
public String Type;
public DateTime TimeStamp;
public String SenderID;
public Object Content;
public InMessage()
{
IsSubscription = false;
Type = "";
TimeStamp = DateTime.Now;
SenderID = "";
Content = "";
}
public InMessage(bool isSubscription, String type, DateTime timeStamp, String senderID, Object content)
{
IsSubscription = isSubscription;
Type = type;
TimeStamp = timeStamp;
SenderID = senderID;
Content = content;
}
public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
{
info.AddValue("IsSubscription", IsSubscription);
info.AddValue("Type", Type);
info.AddValue("TimeStamp", TimeStamp);
info.AddValue("SenderID", SenderID);
info.AddValue("Content", Content);
}
}