[Mono-dev] wsdl.exe causes System.InvalidCastException

mikelenner mike.lenner at gmail.com
Tue Aug 26 15:21:41 EDT 2008


I've stepped through wsdl.exe with the mono debugger and found the issue.  I
think this is a bug in XmlSchemaImporter.

The line in that file that throws the InvalidCastException is within
ImportDerivedTypeMapping:

RegisterMapFixup (map, qname, (XmlSchemaComplexType)stype);

Examining the local variable stype in the debugger, I see it is of type
XmlSchemaSimpleType which is why the above line throws the excpetion:

* (mdb) p stype
(System.Xml.Schema.XmlSchemaSimpleType) { <System.Xml.Schema.XmlSchemaType>
= 
...

The schema element in question is this:
<xsd:element name="license">
    <xsd:simpleType>
        <xsd:restriction base="xsd:string"/>
    </xsd:simpleType>
</xsd:element>

If I change the above schema excerpt to the equivalent I no longer see the
exception is wsdl.exe:
<xsd:element name="license" type="xsd:string" />


mikelenner wrote:
> 
> [resending as I'm now subscribed to the right mailing list]
> 
> Specifically, when running wsdl.exe to create my client stub, I get the
> following exception:
> 
> System.InvalidCastException: Cannot cast from source type to destination
> type.
>   at System.Xml.Serialization.XmlSchemaImporter.ImportDerivedTypeMapping
> (System.Xml.XmlQualifiedName name, System.Type baseType, Boolean
> baseTypeCanBeIndirect) [0x00000] 
>   at System.Xml.Serialization.XmlSchemaImporter.ImportDerivedTypeMapping
> (System.Xml.XmlQualifiedName name, System.Type baseType) [0x00000] 
>   at System.Web.Services.Description.SoapProtocolImporter.ImportHeader
> (System.CodeDom.CodeMemberMethod method,
> System.Web.Services.Description.SoapHeaderBinding hb, SoapHeaderDirection
> direction) [0x00000] 
>   at System.Web.Services.Description.SoapProtocolImporter.ImportHeaders
> (System.CodeDom.CodeMemberMethod method) [0x00000] 
>   at System.Web.Services.Description.SoapProtocolImporter.GenerateMethod
> (System.Xml.Serialization.CodeIdentifiers memberIds,
> System.Web.Services.Description.SoapOperationBinding soapOper,
> System.Web.Services.Description.SoapBodyBinding bodyBinding,
> System.Xml.Serialization.XmlMembersMapping inputMembers,
> System.Xml.Serialization.XmlMembersMapping outputMembers) [0x00000] 
>   at System.Web.Services.Description.SoapProtocolImporter.GenerateMethod
> () [0x00000] 
>   at System.Web.Services.Description.ProtocolImporter.ImportPortBinding
> (Boolean multipleBindings) [0x00000] 
>   at System.Web.Services.Description.ProtocolImporter.Import
> (System.Web.Services.Description.ServiceDescriptionImporter
> descriptionImporter, System.CodeDom.CodeNamespace codeNamespace,
> System.Collections.ArrayList importInfo) [0x00000] 
>   at System.Web.Services.Description.ServiceDescriptionImporter.Import
> (System.CodeDom.CodeNamespace codeNamespace,
> System.CodeDom.CodeCompileUnit codeCompileUnit) [0x00000] 
>   at Mono.WebServices.SourceGenerator.GenerateCode
> (System.Collections.ArrayList descriptions, System.Collections.ArrayList
> schemas) [0x00000] 
>   at Mono.WebServices.Driver.Run (System.String[] args) [0x00000]
> 
> Is there any way to tell what part of my wsdl is causing this?  Has anyone
> experienced similar issues?  I saw a similar post in someone seeing this
> exception when running stubs created by wsdl.exe.  However, there was no
> resolution on that thread.  
> 
> Thanks,
> Mike
> 

-- 
View this message in context: http://www.nabble.com/wsdl.exe-causes-System.InvalidCastException-tp19152234p19168560.html
Sent from the Mono - Dev mailing list archive at Nabble.com.



More information about the Mono-devel-list mailing list