XmlSerializer formatter = new XmlSerializer(typeof(List<Objects.PIP>));
**MemoryStream stream = new MemoryStream(new byte[1024]);**
formatter.Serialize(stream, Repository.GlobalRepository.PIPInformation);
byte[] bt = stream.ToArray();
foreach (Communication.Client Client in server.ClientList)
{
Client.SendMessage(bt);
}
stream.Flush();
我得到一個錯誤在盯着路線爲:XmlSerializer的,有一個錯誤生成XML文檔時
時出錯生成XML文檔。
的InnerException { 「記憶流是不可擴展的。」}
PIP Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ObjectLibrary.Model;
using System.Xml.Serialization;
namespace PIPServer.Objects
{
[XmlRoot(Namespace = "urn:my-namespace")]
public class PIP
{
private long pipID;
public long PipID
{
get { return pipID; }
set { pipID = value; }
}
private CurrencyPair currencyPair;
public CurrencyPair CurrencyPair
{
get { return currencyPair; }
set { currencyPair = value; }
}
...............
}
}
我到底做錯了什麼? 也是我的方法轉換流爲字節數組正確? [回答]
這很可能是PIP類中的其他內容。請給我們完整的類定義 – Polity
剛好有其他屬性沒有別的... – thewayman