Kbase P163209: Error 13840 occurs when attempting to instantiate XElement from System.Xml.Linq
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  06/04/2010 |
|
Status: Unverified
SYMPTOM(s):
Error 13840 occurs when attempting to instantiate XElement from System.Xml.Linq
Cannot use NEW statement with class '<Arg1>' because no constructor found with matching signature. (13840)
Cannot use NEW statement with class 'System.Xml.Linq.XElement' because no constructor found with matching signature. (13840)
USING System.*.
USING System.Xml.Linq.*.
DEFINE VARIABLE root AS System.Xml.Linq.XElement.
root = NEW XElement("Root",NEW XElement("Child", 1)).
Equivalent C# code executes as expected
using System;
using System.Xml.Linq;
public class Class1
{
public static void Main(String[] args)
{
XElement root = new XElement("Root", new XElement("Child", "child content"));
Console.WriteLine(root);
}
}
FACT(s) (Environment):
XElement constructor used requires an XName object
XName class has no constructors
XElement static methods (i.e. Load) can be called successfully
OpenEdge 10.2B
Windows
CAUSE:
The C# example works on the basis of overloaded operators of the XName object. ABL does not support operator overloading.
FIX:
Use the static method of XName called Get(<string>) to create an XName object to be used when instantiating an XElement object:
DEFINE VARIABLE root AS System.Xml.Linq.XElement.
DEFINE VARIABLE xnam1 AS System.Xml.Linq.XName.
DEFINE VARIABLE xnam2 AS System.Xml.Linq.XName.
xnam1 = System.Xml.Linq.XName:Get("Root").
xnam2 = System.Xml.Linq.XName:Get("Child").
root = NEW XElement(xnam1, NEW XElement(xnam2, 1)).