Hello all,
I have a class which become a XmlDocument and with a Deserialize put the information in a class (Function LoadConfigSpecific). Ok this work well :)
protected clsConfigGeneric m_cConfigSpecific = null;
private void LoadConfigSpecific()
{
string sXmlInfo = "";
sXmlInfo = m_cXmlDoc.OuterXml;
System.IO.StringReader oStringReader = new System.IO.StringReader(sXmlInfo);
System.Xml.Serialization.XmlSerializer oXmlSer = new System.Xml.Serialization.XmlSerializer(typeof(clsConfigWEBLog));
m_cConfigSpecific = new clsConfigWEBLog();
m_cConfigSpecific = (clsConfigWEBLog)oXmlSer.Deserialize(oStringReader);
}
In a other function I will do the opposite save the class which I have to a XmlDocument. Like do you can see in the function SaveConfigSpecific. But it don't work :sigh:
private void SaveConfigSpecific()
{
System.Xml.Serialization.XmlSerializer oXmlSer = new System.Xml.Serialization.XmlSerializer(typeof(clsConfigWEBLog));
oXmlSer.Serialize(oStream, Config);
m_cXmlDoc.Load(oStream);
raiseOnEvChangeConfig();
}
Exactly what happen is when they will load the data to the XmlDoc
m_cXmlDoc.Load(oStream);
they will exit with a Error Exception
System.Xml.XmlException - Message = "Falta el elemento raíz." (="Root Element Failed!");
Can me please say how I do bad :((
For your information the Class from which I Load the Data to the XmlDoc is the Following, and they have a Root Element
[XmlRoot("Config")]
public class clsConfigWEBLog : clsConfigGeneric
{
#region Variables
private System.DateTime m_dtLastUpdate = new DateTime();
private clsFtp m_cFtp = new clsFtp();
private clsTimers m_cTimers = new clsTimers();
private clsSaveFile m_cSaveFile = new clsSaveFile();
#endregion
#region Probiedades
[XmlAttributeAttribute(DataType = "date")]
public System.DateTime LastUpdate
{
get
{
return m_dtLastUpdate;
}
set
{
try
{
m_dtLastUpdate = value;
}
catch (Exception eLastUpdate)
{
Console.WriteLine("Error al cargar el Valor LastUpdate: " + eLastUpdate.Message);
}
}
}
[XmlElement(typeof(clsFtp))]
public clsFtp Ftp
{
get
{
return m_cFtp;
}
set
{
m_cFtp = value;
}
}
[XmlElement(typeof(clsTimers))]
public clsTimers Timers
{
get
{
return m_cTimers;
}
set
{
m_cTimers = value;
}
}
[XmlElement(typeof(clsSaveFile))]
public clsSaveFile SaveFile
{
get
{
return m_cSaveFile;
}
set
{
m_cSaveFile = value;
}
}
#endregion
}