开发者

Troubleshooting XmlSerializer.Deserialize()

How does one troubleshoot/debug deserialization with XmlSerializer, i.e. XmlSerializer.Deserialize()? Is there anyway to find o开发者_开发问答ut why an element in the document wasn't deserialized? Or is it just trial and error?

I have a document that I am trying to deserialize and one of the properties of the target object is null after deserialization, but the element is populated in the document.

Thanks.


If it threw an exception, the reasons would be in the InnerException. If is didn't, it probably means simply not matching layout:

  • name mismatch (including case)
  • namespace
  • attribute vs element
  • for repeated data, element vs array, and array-level

Of course a broken `set is an option too. An example of the XML and c# (for the affected data) would probably reveal all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜