G
Guest
Guys please post your comments to (e-mail address removed)
using System;
using System.Xml;
using System.IO;
using System.Xml.Serialization;
namespace ConsoleApplication1
{
[Serializable()]
public class tResponseGeneralInfo
{
public long ProfileNumber;
public bool ProfileNumberSpecified;
}
class Class1
{
[STAThread]
static void Main(string[] args)
{
tResponseGeneralInfo obj = new tResponseGeneralInfo();
obj.ProfileNumber = 23;
XmlDocument oXmlDoc = new XmlDocument();
oXmlDoc.Load(m_Serialize(obj));
}
private static MemoryStream m_Serialize(object obj)
{
try
{
XmlSerializer serializer = new XmlSerializer(obj.GetType());
MemoryStream ms = new MemoryStream();
System.IO.StreamWriter sw = new StreamWriter("C:\\test.txt");
serializer.Serialize(sw, obj);
ms.Position = 0;
sw.Close();
return ms;
}
catch(Exception ex)
{
throw ex;
}
}
}
}
Now ProfileNumber is missing, the funny party is when i change the variable
name ProfileNumberSpecified to something else it starts working
"<?xml version=\"1.0\"?><tResponseGeneralInfo
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><ProfileNumberSpecified>false</ProfileNumberSpecified></tResponseGeneralInfo>"
using System;
using System.Xml;
using System.IO;
using System.Xml.Serialization;
namespace ConsoleApplication1
{
[Serializable()]
public class tResponseGeneralInfo
{
public long ProfileNumber;
public bool ProfileNumberSpecified;
}
class Class1
{
[STAThread]
static void Main(string[] args)
{
tResponseGeneralInfo obj = new tResponseGeneralInfo();
obj.ProfileNumber = 23;
XmlDocument oXmlDoc = new XmlDocument();
oXmlDoc.Load(m_Serialize(obj));
}
private static MemoryStream m_Serialize(object obj)
{
try
{
XmlSerializer serializer = new XmlSerializer(obj.GetType());
MemoryStream ms = new MemoryStream();
System.IO.StreamWriter sw = new StreamWriter("C:\\test.txt");
serializer.Serialize(sw, obj);
ms.Position = 0;
sw.Close();
return ms;
}
catch(Exception ex)
{
throw ex;
}
}
}
}
Now ProfileNumber is missing, the funny party is when i change the variable
name ProfileNumberSpecified to something else it starts working
"<?xml version=\"1.0\"?><tResponseGeneralInfo
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><ProfileNumberSpecified>false</ProfileNumberSpecified></tResponseGeneralInfo>"