0
我有一個類的下面的C#代碼,我創造的,我想在這一直給我的出現InvalidOperationException一個的MessageQueue發送對象「時出錯發生XML文件「,我無法弄清楚如何擺脫。我究竟做錯了什麼?時出錯生成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);
}
}
什麼是內部異常?通常有一連串的內部例外,告訴你到底發生了什麼問題。 –
另外,請顯示您用來序列化的代碼。 –
我認爲你傳遞給Content的對象會導致這個錯誤。嘗試傳遞一個null,看看你是否仍然得到這個錯誤。 – I4V