Enumeration has not started. Call MoveNext

Posted: March 13, 2018  |  Categories: BizTalk

Testing a BizTalk 2013 R2 map  I got this error; “Enumeration has not started. Call MoveNext”. What on earth does this mean?

#1 Azure Monitoring Platform

A quick search reveals this Microsoft article about known issues when migrating BizTalk 2010 maps to BizTalk 2013.  Indeed the map contains two scripting  functoids  that convert an XMLpayload to  a string with this code in it.

The problem code is

public static string NodeToString(XPathNodeIterator nodes)
{
return nodes.Current.OuterXml;
};

First attempted solution –  Call MoveNext

The Microsoft solution requires the addition of the node.MoveNext() call. This old blog of mine describes how to convert an XML payload to a string and I had added this call as shown below;

namespace CopyXML2TextNodeBTSDemo.Utility
{
public class Utilities
{
public static string ConvertNodeToXmlString(XPathNodeIterator node)
{      node.MoveNext();
return node.Current.OuterXml;
}
}
}

The Final Solution

Unfortunately adding this call to the scripting functoids above I still does not resolve the error. In the end replacing the scripting functoid with a custom XSLT template resolves the issue. The script is shown below;

<!–Converts XML node to string.–>

<xsl:template name=”convertXML2Text”>
<xsl:param name=”XMLnode” />
<xsl:element name=”ns0:XML”>
<xsl:text disable-output-escaping=”yes”>&lt;![CDATA[</xsl:text>
<xsl:call-template name=”identity” />
<xsl:text disable-output-escaping=”yes”>]]&gt;</xsl:text>
</xsl:element>
</xsl:template>
<xsl:template name=”identity” match=”@*|node()”>
<xsl:copy>
<xsl:apply-templates select=”@*|node()” />
</xsl:copy>
</xsl:template>

Conclusion

Be careful migrating BizTalk 2010 maps to BizTalk 2013 R2 maps and test everyone. I have shown that you can use a custom XSLt template to get around the error “Enumeration has not started. Call MoveNext”.

#1 Azure Monitoring Platform
turbo360

Back to Top