我有一个模式文件,我曾用Cs和xsd2code生成相应的类。 当我在VS2010调试器中运行应用程序时,我从我的xml文件中获取所有数据,但是当我从cmd运行.exe时,某些数据未加载。 任何想法为什么或如何找出原因?
...
// reading file storing into a buffer
Stream bufStream = new MemoryStream(buffer);
using (TextReader textReader = new StreamReader(bufStream))
{
XmlSerializer deserializer = new XmlSerializer(typeof(ReportTypeFromXSD));
ReportTypeFromXSD rep = (ReportTypeFromXSD)deserializer.Deserialize(textReader);
...
foreach(PersonType person in rep.Persons)
{
...
// check if the node data is present
if( person.residentialHist != null && person.residentialHist.Count > 0 )
{
// Log how many there and load Into DB
}
// check if the node data is present
if( person.employmentHist != null && person.employmentHist.Count > 0 )
{
// Log how many there and load Into DB
}
...
}
}
所以,当我从调试器运行时,我总是会加载就业历史记录,但是当我将它作为一个Windows任务运行时,我根本没有获得就业历史记录。
谢谢, 珍妮