1,272 questions
I think that TResponse was not Error in your call of XmlStringToObject<TResponse>.
Or maybe the real details were different.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi, Everybody!
I need to deserialize the following XML...
<?xml version="1.0" encoding="utf-8"?>
<Error>
<Message> There is an error in....</Message>
</Error>
I defined the following class...
[XmlRoot(ElementName="Error")]
public class Error {
[XmlElement(ElementName="Message")]
public string Message { get; set; }
}
When I attempt to deserialize...
private TResponse XmlStringToObject<TResponse>(string xmlString)
{
using (var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(xmlString)))
{
var xmlSerializer = new XmlSerializer(typeof(TResponse));
return (TResponse)xmlSerializer.Deserialize(memoryStream);
}
}
I get the following error message...
System.InvalidOperationException HResult=0x80131509 Message=There is an error in XML document (1, 40). Source=<Cannot evaluate the exception source> Inner Exception 1: InvalidOperationException: <Error xmlns=''> was not expected.
What am I doingwrong?
I think that TResponse was not Error in your call of XmlStringToObject<TResponse>.
Or maybe the real details were different.