EDN Admin
Well-known member
I have a schema document that I am trying to generate a C# class from using the xsd.exe tool. When I run the tool, it crashes with the error "Object reference not set to an instance of an object". I have located the source of the error and I
dont understand why it should be an error. One of the lines in my schema document looks like this:
<<span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small xs:element<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small
<span style="font-family:Consolas; color:#ff0000; font-size:x-small <span style="font-family:Consolas; color:#ff0000; font-size:x-small <span style="font-family:Consolas; color:#ff0000; font-size:x-small name<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small =<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; color:#000000; font-size:x-small "<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small controller<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; color:#000000; font-size:x-small "<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small
<span style="font-family:Consolas; color:#ff0000; font-size:x-small <span style="font-family:Consolas; color:#ff0000; font-size:x-small <span style="font-family:Consolas; color:#ff0000; font-size:x-small minOccurs<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small =<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; color:#000000; font-size:x-small "<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small 0<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; color:#000000; font-size:x-small "<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small
<span style="font-family:Consolas; color:#ff0000; font-size:x-small <span style="font-family:Consolas; color:#ff0000; font-size:x-small <span style="font-family:Consolas; color:#ff0000; font-size:x-small maxOccurs<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small =<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; color:#000000; font-size:x-small "<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small 0<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; color:#000000; font-size:x-small "<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small >
If I remove either the minOccurs or maxOccurs attribute so that both do not exist at the same time, xsd.exe successfully generates a class.
My question is why this should cause xsd.exe to crash. According to http://www.w3.org
www.w3.org , it is perfectly valid to have both elements.
Thoughts?
<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small
<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small
<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small
View the full article
dont understand why it should be an error. One of the lines in my schema document looks like this:
<<span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small xs:element<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small
<span style="font-family:Consolas; color:#ff0000; font-size:x-small <span style="font-family:Consolas; color:#ff0000; font-size:x-small <span style="font-family:Consolas; color:#ff0000; font-size:x-small name<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small =<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; color:#000000; font-size:x-small "<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small controller<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; color:#000000; font-size:x-small "<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small
<span style="font-family:Consolas; color:#ff0000; font-size:x-small <span style="font-family:Consolas; color:#ff0000; font-size:x-small <span style="font-family:Consolas; color:#ff0000; font-size:x-small minOccurs<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small =<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; color:#000000; font-size:x-small "<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small 0<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; color:#000000; font-size:x-small "<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small
<span style="font-family:Consolas; color:#ff0000; font-size:x-small <span style="font-family:Consolas; color:#ff0000; font-size:x-small <span style="font-family:Consolas; color:#ff0000; font-size:x-small maxOccurs<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small =<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; color:#000000; font-size:x-small "<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small 0<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; color:#000000; font-size:x-small "<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small >
If I remove either the minOccurs or maxOccurs attribute so that both do not exist at the same time, xsd.exe successfully generates a class.
My question is why this should cause xsd.exe to crash. According to http://www.w3.org
www.w3.org , it is perfectly valid to have both elements.
Thoughts?
<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small
<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small
<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small
View the full article