生成XML文档 - 工作类时出错

时间:2013-05-20 18:35:15

标签: c# xml-serialization msmq

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

1 个答案:

答案 0 :(得分:0)

该错误实际上与此类无关,但格式化程序存在问题。