Microsoft Developer Network > Forums Home > Windows Networking Development Forums > Windows Web Services API > 0x80070057: "A structure that supports derivation may not be used in this context."
Ask a questionAsk a question
 

Answer0x80070057: "A structure that supports derivation may not be used in this context."

  • Monday, October 12, 2009 1:48 PMAndy McMullan Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I'm using a WWSAPI proxy to talk to a WCF service.   I had a basic interface working fine, but now I've made my interface a little more complex, I'm getting the above error at run-time when I invoke a method.  Tracing indicates the error is coming from WsCall, but gives no more details.  

    I'm using inheritance which I presume is the source of the problem, even though the documentation claims that xsd extension is supported, and wsutil seems to handle the interface fine.   The code is a little complex to post - before I put the effort into producing a concise repro, does anyone know a likely cause of this error? 

    Thanks

    Andy

Answers

  • Wednesday, October 14, 2009 6:04 AMHao Xu - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    This is a known limitation in our current release. We are looking into supporting non-nillable array elements with base types in the next release.
    • Marked As Answer byAndy McMullan Wednesday, October 14, 2009 7:12 PM
    •  

All Replies

  • Monday, October 12, 2009 5:05 PMAndy McMullan Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I've got this narrowed down a bit more.  The error occurs when I have a class that contains an array of base class objects, and I use the XmlElement attribute on the array, e.g.:

    [Serializable]
    class MyClass
    {
         [XmlElement(ElementName = "BaseObject")]
         public Base[] BaseObjects;
    }

    The problem only occurs if Base has some derived classes, e.g.

    [Serializable]
    [XmlInclude(typeof(Derived))]
    class Base
    {
    }

    If I remove the XmlElement from the BaseObjects field, everything works fine.

    At the XSD level, the problem form is:

    <xs:complexType name="MyClass">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="BaseObject" type="tns:Base" />
    </xs:sequence>
    </xs:complexType>

    whereas the working form is:

    <xs:complexType name="MyClass">
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="1" name="BaseObjects" type="tns:ArrayOfBase" />
      </xs:sequence>
    </xs:complexType>

    <xs:complexType name="ArrayOfBase">
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" name="Base" nillable="true" type="tns:Base" />
      </xs:sequence>
    </xs:complexType>

    It's not obvious to me why the latter works but the former doesn't.  But now that I know what causes the problem, I can work around it.

     

  • Wednesday, October 14, 2009 6:04 AMHao Xu - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    This is a known limitation in our current release. We are looking into supporting non-nillable array elements with base types in the next release.
    • Marked As Answer byAndy McMullan Wednesday, October 14, 2009 7:12 PM
    •