This project is read-only.

XIncludingReader with XmlSerializer

Topics: User Forum
May 19, 2010 at 11:30 AM

Hi MVPers.

I'm sure I'm doing something really silly, I just haven't quite figured out what.

Basically all I want to do is to deserialize some hand-crafted XML, hydrating some XSD.exe generated classes. The hand-crafted XML uses XInlcude so I'm using XIncludingReader to read it in; according to the release notes for v2.3, XIncludingReader with XMLSerializer is a supported scenario. In addition, I also want the hand-crafted XML validated, so I'm using a Schema Set for that.

Unfortunately, deserialization fails for me. The problem appears to be in the autogenerated XmlSerialization code, more specifically in Reader.MoveToElement() call of ReadXX_Templates; for some reason this does not result in moving back to the Templates element, as one would expect after all attributes have been read (the last attribute is xml:base, not sure if this is important or not).

My environment is Visual Studio 2008, .Net Framework 3.5.

I've got a small project that illustrates the issue, but haven't quite figured out how to use attachments in this forum. I'll attach it on a subsequent post. Once the project has been uploaded, you should be able to see the problem by ticking Debug | Exceptions | Common Language Runtime Exceptions | Thrown and F5'ing it. The Reader.MoveToElement is just above the place where the exception is thrown.

Many thanks for your time.

Constraint has encouraged not only economy, but also a certain elegance of design. -- dennis ritchie and ken thompson.

May 19, 2010 at 11:40 AM

Actually, struggling with the attachments - if anyone knows how to add an attachment to a post pls let me know. Alternatively, I can email the zip to anyone interested - its only 100 Kb.