PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework XML Serialization in .net CF

Reply

XML Serialization in .net CF

 
Thread Tools Rate Thread
Old 13-09-2006, 06:07 PM   #1
=?Utf-8?B?TmlsZXNo?=
Guest
 
Posts: n/a
Default XML Serialization in .net CF


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;
}
}
  Reply With Quote
Old 19-09-2006, 10:19 PM   #2
Kay-Christian Wessel
Guest
 
Posts: n/a
Default Re: XML Serialization in .net CF

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

"Nilesh" <Nilesh@discussions.microsoft.com> wrote in message
news:4F98A2A4-B25E-4193-A03F-714D25CBEF08@microsoft.com...
> 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;
> }
> }



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off