0

I am using XSD2Code to generate C# class from XSD file.

I got stuck with the following problem.

XML file looks something like

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Notification xmlns="http://message.domain.com">
  <Object xmlns="http://type.domain.com" ID="97440" />
</Notification>

XML gets succefsully deserialized when xmls for Object is empty. But when there is a value like in the sample above, I get an error "Object reference not set to an instance of an object".

What could cause this error?

mko
  • 6,638
  • 12
  • 67
  • 118

2 Answers2

0

you have to change the Serializer to something like that

private static System.Xml.Serialization.XmlSerializer Serializer
{
    get
    {
        if ((serializer == null))
        {
            serializer = new System.Xml.Serialization.XmlSerializer(typeof(Notification), "http://message.domain.com");
        }
        return serializer;
    }
}
masterchris_99
  • 2,683
  • 7
  • 34
  • 55
0

To turn off encoding, disable encoding on the Serialization tab

David Andrews
  • 71
  • 2
  • 8