[Mono-list] Datasets passed between methods loses data
anthony whalley
tont@o2.ie
Mon, 07 Mar 2005 00:19:46 +0000 (GMT)
Hi All
I am writing an application that marshells a log4net
file into a dataset and then passes the dataset
over to another method. I am using v 1.1.4 from the
RPMs on Suse 9.2 and below is the code.
However when I test the dataset returned it
has only a root node even though before
it is passed it has all the data inside it.
I have solved the prolem for now by passing over
the data as a string type and marhalling the
data there but wondered if I should
report it as a bug??
public class obj{
public DataSet GetLogFile()
{
DataSet ds = new DataSet() ;
try
{
string _logLocation = Environment.CurrentDirectory + Path.DirectorySeparatorChar + "server.log" ;
Stream stm = File.Open(_logLocation, FileMode.Open, FileAccess.Read, FileShare.ReadWrite) ;
StreamReader str = new StreamReader(stm) ;
ds.ReadXml(new StringReader("<root xmlns:log4net='http://logging.apache.org/log4net/LogSchema'>" +
str.ReadToEnd() +
"</root>")) ;
str.Close();
stm.Close();
}
catch(Exception e)
{
log.Error("Get log file error", e) ;
}
return ds ;
}
}
public class otherObj
{
obj o = new obj() ;
DataSet ds = new DataSet() ;
public void testxml(){
ds = o.GetLogFile() ;
Console.WriteLine(ds.GetXml()); //returns <root />
}
}