1
Intermittent exception when calling ToXmlElement
Problem reported by Brian Mason - 6/23/2017 at 9:02 AM
Resolved
Hi
 
When calling ToXmlElement we see an intermittent exception...

LiquidTechnologies.Runtime.Net45.LtValidationException: Failed to convert the element [Document] to XML ---> System.ArgumentException: The attribute local name cannot be empty.
at System.Xml.XmlAttribute..ctor(XmlName name, XmlDocument doc)
at System.Xml.XmlDocument.CreateAttribute(String prefix, String localName, String namespaceURI)
at LiquidTechnologies.Runtime.Net45.Element.ToXml(XmlWriter xmlOut, Boolean bNamespace, String namespaceUri, XmlSerializationContext context, Boolean isOptionalChoice)
at LiquidTechnologies.Runtime.Net45.ElementInfoAttribute.ElementToXmlCls(XmlSerializationContext context, XmlObjectBase parentObj, XmlWriter xmlOut, Boolean isOptionalChoice)
at LiquidTechnologies.Runtime.Net45.ElementInfoSeqUntpdOptAttribute.ElementToXml(XmlSerializationContext context, XmlObjectBase parentObj, XmlWriter xmlOut)
at LiquidTechnologies.Runtime.Net45.XmlGeneratedClass.ProcessElementSeqToXml(XmlSerializationContext context, XmlWriter xmlOut)
at LiquidTechnologies.Runtime.Net45.XmlGeneratedClass.ToXml(XmlWriter xmlOut, Boolean bRootElement, String namespaceUri, XmlSerializationContext context, Boolean isOptionalChoice)
--- End of inner exception stack trace ---
 
The app is running as a service and the method is called via an exposed API from an external system. It initially works OK, but then the exception is thrown. If I reset, it works again for a bit then fails.
 
Please provide a fix as this is critical for my project.
 
Thanks
 
 

1 Reply

Reply to Thread
1
Liquid Support Replied
Employee Post
Hi Brian,
 
This sounds like a multi-threading issue with regards to using static values.
 
Please see the knowledge base article:
 
If you open the generated file 'Enumerations.cs', you should see a section where the default static XmlSerializationContext builds its internal namespace map. If you copy this code, you can build your own local XmlSerializationContext and pass this context in to all calls to FromXml...  and ToXml...
 
If this is not the issue, please create a support ticket and send a zip of your project with a sampleapp so we can try to replicate the issue.
 

Reply to Thread