Performance Issue With Xml Serilization with WCF Service
hi
We are using the blow given code for serilization and deserilization for class members. but we are geting performance issue. 75% of whole lode of application we are geting with only serilization and deserilization process with this code. is there any other way for the same process. publicstaticstring SerializeDTO(DTO dto) { try { XmlSerializer xmlSer = new XmlSerializer(dto.GetType()); StringWriter sWriter = new StringWriter(); // Serialize the dto to xml. xmlSer.Serialize(sWriter, dto); // Return the string of xml. return sWriter.ToString(); } catch(Exception ex) { // Propogate the exception. throw ex; } }
/// /// Deserializes the xml into a specified data transfer object. /// /// string of xml /// type of dto /// DTO publicstatic DTO DeserializeXml(string xml, DTO dto) { try { XmlSerializer xmlSer = new XmlSerializer(dto.GetType()); // Read the XML. StringReader sReader = new StringReader(xml); // Cast the deserialized xml to the type of dto. DTO retDTO = (DTO)xmlSer.Deserialize(sReader); // Return the data transfer object. return retDTO; } catch(Exception ex) { // Propogate the exception. throw ex; } }