XML Serialization in .net CF

G

Guest

To send/receive data to/fro PDA or Web Service, I have created Translation
class which contain collection of objects which I need to transfer from one
end to another.
The web service calls the serialize method of EntityTranslation class to
Serialize the data and the win forms application call the deserialize method
to get the data.
It all works fine in win forms application, problem occurs when I try to
deserialize it from Device Application (Pocket PC). It fails on line
XmlSerializer s = new XmlSerializer(this.GetType());
in the Deseralize method with error
An error message cannot be displayed beacuase an optional resource assembly
containing it cannot be found.


I don't want to use datasets to transfer data from to and from PDA/Web
service as it is not the best approach???


public class EntityTranslation
{
private Lookups lookups = new Lookups();
public Lookups LookupCollection
{
get { return lookups; }
set { lookups = value; }
}
public string Seralize()
{
String strOutput = string.Empty;
XmlSerializer s = new XmlSerializer(this.GetType());
StringWriter strWriter = new StringWriter();

try
{
s.Serialize(strWriter, this);
strOutput = strWriter.ToString();
}
finally
{
strWriter.Close();
}
return strOutput;
}
public static EntityTranslation Deseralize(string xmlString)
{
EntityTranslation etObj = new EntityTranslation();
StringReader strReader = new StringReader(xmlString);
XmlSerializer serializer = new XmlSerializer(etObj.GetType());
try
{
etObj = (EntityTranslation)serializer.Deserialize(strReader);
}
finally
{
strReader.Close();
}
return etObj;
}
}
 
K

Kay-Christian Wessel

To get the real error message you need to add a reference to System.SR.dll.
This is recommended by Microsoft.

Deserializing xml on a pda is typically a slow process. You should consider
other ways to do this, like your own binary format, which will be much
faster.

Best regards
Kay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top