我有以下類別:序列化問題
[Serializable]
public class TradeBotSettings
{
public ExchangePlatform Exchange
{
get;
set;
}
}
[Serializable]
public enum ExchangePlatform
{
[XmlEnum("BTC_E")]
BTC_E,
[XmlEnum("BitStamp")]
BitStamp,
[XmlEnum("CampBX")]
CampBX,
[XmlEnum("Cryptsy")]
Cryptsy,
[XmlEnum("BTCChina")]
BTCChina,
}
當我試圖序列給出錯誤
private void Button2_Click(object sender, EventArgs e)
{
TradeBotSettings tbSettings = new TradeBotSettings();
tbSettings.Exchange = ExchangePlatform.BTC_E;
StreamWriter sw = new StreamWriter(@"D:\Temp\Trader\Trader\Trader\bin\x86\Debug\configs\bots.xml", false);
xmlSerializerTradebot = new XmlSerializer(tbSettings.GetType());
xmlSerializerSettings.Serialize(sw, tbSettings);
sw.Close();
}
錯誤是:「System.InvalidOperationException」類型的未處理的異常出現在系統.Xml.dll
附加信息:生成XML文檔時發生錯誤。
這看起來像一個普通的錯誤任何人有一個關於這個
感謝線索事先
是'xmlSerializerSettings.Serialize(sw,tbSettings);'一個錯字?那不會編譯。 –
不明白對不起 –