I can only get the behaviour you're describing by changing the type of your Log.PrOrNumber property to int or int?, and Kilazur's second link corrects the issue in my reproduction - you're certain you followed through with what it suggested correctly?
In my reproduction case, the serialiser's getting stuck trying to parse an empty string into an integer. To fix, we expose a string property PrOrNumberRaw
for the serialiser to talk to that contains the required parsing logic, and our own property PrOrNumber
with the parse value (or null) for the application to consume.
The Log class definition changes to become:
[XmlRoot("Log")]
[Serializable]
public class Log
{
public Log() { }
[XmlElement("InterfaceID")]
public string InterfaceID { get; set; }
[XmlElement("MESKey")]
public string MESKey { get; set; }
[XmlElement("MsgStatusCode")]
public string MsgStatusCode { get; set; }
[XmlElement("MsgClass")]
public string MsgClass { get; set; }
[XmlElement("MsgNumber")]
public string MsgNumber { get; set; }
[XmlElement("MsgDescription")]
public string MsgDescription { get; set; }
[XmlElement("PrOrNumber")]
public string PrOrNumberRaw
{
get { return this.PrOrNumber.ToString(); }
set
{
if (!string.IsNullOrWhiteSpace(value))
{
this.PrOrNumber = int.Parse(value);
}
else
{
this.PrOrNumber = null;
}
}
}
[XmlIgnore]
public int? PrOrNumber { get; set; }
}