生成XML文档- Working Class时出错

本文关键字:Class 出错 Working XML 文档 生成 | 更新日期: 2023-09-27 18:14:22

我有一个类的以下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);
    }
}

生成XML文档- Working Class时出错

这个错误实际上与这个类无关,而是格式化程序的问题。