XmlSerializer.Deserialize and missing classes

Y

yuriy_zubarev

Greetings,

I've got a XML file that I deserialize into an object using
XmlSerializer:

<?xml version="1.0" encoding="utf-8"?>
<factory
xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<widgets>
<widget xsi:type="WidgetA">
</widget>
<widget xsi:type="WidgetB">
</widget>
</widgets>
</factory>

Everything is just fine when I provide XmlSerializer with extra types
for WidgetA and WidgetB classes. The question is how to handle a
situation when, for example, the app doesn't know anything about
WidgetB class (a plug-in isn't installed and so on). Right now
InvalidOperationException occures but ideally I would like <widget> tag
for WidgetB to be skipped with no interruption for deserialization
process.

Any advices, approaches?

Regards,
Yuriy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top