c# - Serialization issue on custom type -


i have following classes:

 [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,     } 

when try serialize gives error

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();         } 

error : unhandled exception of type 'system.invalidoperationexception' occurred in system.xml.dll

additional information: there error generating xml document.

this looks generic error have clue this

thanks in advance

the code presented wont compile, xmlserializersettings unknown. should have been "xmlserializertradebot.serialize(..." instead, , works fine. maybe that´s problem?

btw: should use "using" clause when creating streamwriter instances prevent having file not closed in case of serialization exceptions. dont need use xmlenum attribute unless want have default serialization behaviour enums changed...

btw2: yeah, know, not clear answer problem , should rather comment. if could... ;-)


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -