private object ReadRoot(Type type) { try { this.m_reader.MoveToContent(); TypeMapping typeMapping = TypeMapper.GetTypeMapping(type); if (this.m_reader.NamespaceURI != typeMapping.Namespace) { throw new XmlException(SRErrors.NoRootElement); } return(this.ReadObject(type, null, 0)); } catch (XmlException) { throw; } catch (Exception ex2) { Exception ex3 = ex2; if (ex3 is TargetInvocationException && ex3.InnerException != null) { ex3 = ex3.InnerException; } string message; if (ex3 is TargetInvocationException) { MethodBase targetSite = ((TargetInvocationException)ex3).TargetSite; string methodName = (targetSite != null) ? (targetSite.DeclaringType.Name + "." + targetSite.Name) : null; message = SRErrors.DeserializationFailedMethod(methodName); } else { message = SRErrors.DeserializationFailed(ex3.Message); } IXmlLineInfo xmlLineInfo = this.m_reader as IXmlLineInfo; XmlException ex4 = (xmlLineInfo == null) ? new XmlException(message, ex3) : new XmlException(message, ex3, xmlLineInfo.LineNumber, xmlLineInfo.LinePosition); throw ex4; } }
private object ReadRoot(Type type) { try { m_reader.MoveToContent(); TypeMapping typeMapping = TypeMapper.GetTypeMapping(type); if (m_reader.NamespaceURI != typeMapping.Namespace) { throw new XmlException(SRErrors.NoRootElement); } return(ReadObject(type, null, 0)); } catch (XmlException) { throw; } catch (Exception innerException) { if (innerException is TargetInvocationException && innerException.InnerException != null) { innerException = innerException.InnerException; } string message; if (innerException is TargetInvocationException) { MethodBase targetSite = ((TargetInvocationException)innerException).TargetSite; message = SRErrors.DeserializationFailedMethod((targetSite != null) ? (targetSite.DeclaringType.Name + "." + targetSite.Name) : null); } else { message = SRErrors.DeserializationFailed(innerException.Message); } IXmlLineInfo xmlLineInfo = m_reader as IXmlLineInfo; XmlException ex2 = (xmlLineInfo == null) ? new XmlException(message, innerException) : new XmlException(message, innerException, xmlLineInfo.LineNumber, xmlLineInfo.LinePosition); throw ex2; } }