/// <summary> /// Reads a Fault reply from the service. /// </summary> /// <param name="reader">The reader, which should start at the "Fault" element.</param> /// <param name="operationName">Name of the operation.</param> /// <returns>A FaultException with the details in the server reply</returns> private static FaultException <DomainServiceFault> ReadFaultException(System.Xml.XmlDictionaryReader reader, string operationName) { FaultCode faultCode; FaultReason faultReason; List <FaultReasonText> faultReasons = new List <FaultReasonText>(); reader.ReadStartElement("Fault"); // <Fault> reader.ReadStartElement("Code"); // <Code> reader.ReadStartElement("Value"); // <Value> faultCode = new FaultCode(reader.ReadContentAsString()); reader.ReadEndElement(); // </Value> reader.ReadEndElement(); // </Code> reader.ReadStartElement("Reason"); while (reader.LocalName == "Text") { var lang = reader.XmlLang; reader.ReadStartElement("Text"); var text = reader.ReadContentAsString(); reader.ReadEndElement(); faultReasons.Add(new FaultReasonText(text, lang)); } reader.ReadEndElement(); // </Reason> faultReason = new FaultReason(faultReasons); reader.ReadStartElement("Detail"); // <Detail> var fault = (DomainServiceFault)s_faultSerializer.ReadObject(reader); return(new FaultException <DomainServiceFault>(fault, faultReason, faultCode, operationName)); }