Error:
{“The specified type was not recognized: name=’VitalsPlugin’,
namespace=”, at .”}
Code:
public class SimpleSerializer
{
static void Main()
{
string xml = "<Plugin xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"VitalsPlugin\" ID=\"eaded5f3-7019-47b9-8f9f-e7c1879774f4\"><CopyForwardChecked>true</CopyForwardChecked></Plugin>";
StringReader reader = new StringReader(xml);
var result = Deserialize(reader);
}
static Plugin Deserialize(TextReader xml)
{
XmlSerializer xsr = new XmlSerializer(typeof(Plugin), new Type[] {typeof(VitalsPlugin)});
Plugin result = xsr.Deserialize(xml) as Plugin;
return result;
}
}
Other useful code:
[XmlInclude(typeof(VitalsPlugin))]
public class Plugin
{
}
public class VitalsPlugin
{
}
After much tinkering I ran across a definition of
xsi:type. After reading the definition I realized that this type specifies a deriving class. I updated the code toand it works.