PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
XML Serialization in .net CF
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
XML Serialization in .net CF
![]() |
XML Serialization in .net CF |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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; } } |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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; > } > } |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

