Accidently, I stumpled across a misformatted XML file having this content:
<?xml version="1.0" encoding="utf-8"?>
<MainModel xmlns:ctl="http://schemas.catelproject.com" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" ctl:graphid="1">
<DataId>123</DataId>
<DataName>Main Data Name</DataName>
<DataCollection ctl:graphid="2">
<SubModel ctl:graphid="3" xmlns:d0p0="http://schemas.datacontract.org/2004/07/CatelSpoiledDerialization.Models" i:type="d0p0:SubModel">
<SubId>200</
As the XML code shows, my example project (https://github.com/thoblerone/CatelSpoiledDerialization) is using the Catel framework, but deep debugging points towards a possible issue in System.Runtime.Serialization.XmlReader
The code to deserialize is pretty straght forward
var iXmlSer = SerializationFactory.GetXmlSerializer();
using var fileStream = File.Open(res.FileName, FileMode.Open);
var myData = iXmlSer.Deserialize<MainModel>(fileStream);
Yet, the call to Deserialize will never finish. Stepping through with the debugger, I see that the underlying .net XmlReader is calling MoveToContent while pointing to defective element (SubId) but the call will never succeed nor does it throw an exception, which I would gladly accept.
Am I missing come xml reader configuration that would check file conformity before tryinto to read the stuff?