System.InvalidOperationException: System.Xml.Linq.XElement cannot be used as: 'xml text'
See original GitHub issueHi. Im running into the same problem as #2150 .
System.InvalidOperationException: There was an error reflecting type ‘ZregService.ManifestType’. —> System.InvalidOperationException: There was an error reflecting property ‘Reference’. —> System.InvalidOperationException: There was an error reflecting type ‘ZregService.ReferenceType’. —> System.InvalidOperationException: There was an error reflecting property ‘DigestMethod’. —> System.InvalidOperationException: There was an error reflecting type ‘ZregService.DigestMethodType’. —> System.InvalidOperationException: There was an error reflecting property ‘Any’. —> System.InvalidOperationException: There was an error reflecting type ‘System.Xml.Linq.XElement’. —> System.InvalidOperationException: System.Xml.Linq.XElement cannot be used as: ‘xml text’. at System.Xml.Serialization.XmlReflectionImporter.CheckContext(TypeDesc typeDesc, ImportContext context) at System.Xml.Serialization.XmlReflectionImporter.ImportSpecialMapping(Type type, TypeDesc typeDesc, String ns, ImportContext context, RecursionLimiter limiter) at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter) — End of inner exception stack trace —
Here is the wsdl wsdl.zip
And here is the generated reference Reference.zip
Seems like it does not like the System.Xml.Linq.XElement Any properties like in:
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil","0.5.0.0")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.w3.org/2000/09/xmldsig#")]
public partial class DigestMethodType
{
private System.Xml.Linq.XElement[] anyField;
private string algorithmField;
/// <remarks/>
[System.Xml.Serialization.XmlTextAttribute()]
[System.Xml.Serialization.XmlAnyElementAttribute(Order=0)]
public System.Xml.Linq.XElement[] Any
{
get
{
return this.anyField;
}
set
{
this.anyField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")]
public string Algorithm
{
get
{
return this.algorithmField;
}
set
{
this.algorithmField = value;
}
}
}
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:12 (7 by maintainers)

Top Related StackOverflow Question
I can confirm that svcutil version 1.0.4 generated a service class that used
XElementinstead ofXmlNode. I [wrongly] thought this was the new way of doing it in dotnet core 2, so I updated my code to match. It broke with a reflection error:there was a problem reflecting type <property>, where property was of typeXElement.I updated the generated service to use XmlNode, and reverted my code changes back to XmlNode, and the service is working, again. How long before this is fixed? It’s not going to impact me much, going forward, but the issue was confusing and this fix is not the best solution (e.g., "fix the generated code every time you regenerate it).
@cjbush I’m sorry this change broke you. There is not a way to generate it using XElement in the latest version. I’d recommend installing the dotnet-svcutil 2.0.0 and using that to generate your service reference.