dotnet/runtime · error · Exception

both count and length property found on: {variable}in templa

Error message

both count and length property found on: {variable}in template: {templateName}

What it means

Raised by parseTemplateNodes() in genEventing.py when a <data> element in a template has both a 'count' attribute and a 'length' attribute set simultaneously. In ETW manifests, count and length are semantically equivalent ways to express array sizing, and specifying both is ambiguous and invalid.

Source

Thrown at src/coreclr/scripts/genEventing.py:367

            nodeMap = dataNode.attributes
            for attrib in nodeMap.values():
                attrib_name = attrib.name
                if attrib_name not in ignoredXmlTemplateAttribes and attrib_name not in usedXmlTemplateAttribes:
                    raise ValueError('unknown attribute: '+ attrib_name + ' in template:'+ templateName)

        for dataNode in dataNodes:
            variable = dataNode.getAttribute('name')
            wintype = dataNode.getAttribute('inType')

            #count and length are the same
            wincount  = dataNode.getAttribute('count')
            winlength = dataNode.getAttribute('length');

            var_Props = None
            var_dependency = [variable]
            if  winlength:
                if wincount:
                    raise Exception("both count and length property found on: " + variable + "in template: " + templateName)
                wincount = winlength

            if (wincount.isdigit() and int(wincount) ==1):
                wincount = ''

            if  wincount:
                if (wincount.isdigit()):
                    var_Props = wincount
                elif  fnPrototypes.getParam(wincount):
                    var_Props = wincount
                    var_dependency.insert(0, wincount)
                    arrays[variable] = wincount

            #construct the function signature

            if  wintype == "win:GUID":
                var_Props = "sizeof(GUID)/sizeof(int)"

View on GitHub (pinned to 60108ba66e)

Solutions

  1. Inspect the <data> element identified by the variable name and template tid in the error message.
  2. Remove either the 'count' or 'length' attribute so only one remains.
  3. Decide which is correct: 'count' indicates array element count, 'length' indicates byte length — use the appropriate one for the data semantics.

Example fix

<!-- before: both count and length specified -->
<data name="Values" inType="win:Int32" count="NumValues" length="4" />

<!-- after: use only count -->
<data name="Values" inType="win:Int32" count="NumValues" />
Defensive patterns

Strategy: validation

Validate before calling

import xml.dom.minidom as DOM

def validate_no_count_length_conflict(manifest_path: str) -> list:
    """Check for <data> elements with both count and length attributes."""
    tree = DOM.parse(manifest_path)
    conflicts = []
    for template in tree.getElementsByTagName('template'):
        tid = template.getAttribute('tid')
        for data in template.getElementsByTagName('data'):
            has_count = bool(data.getAttribute('count'))
            has_length = bool(data.getAttribute('length'))
            if has_count and has_length:
                name = data.getAttribute('name')
                conflicts.append(f"Template '{tid}', data '{name}' has both count and length")
    return conflicts

Type guard

null

Try / catch

try:
    allTemplates = parseTemplateNodes(templateNodes)
except Exception as e:
    if 'both count and length' in str(e):
        print(f"Manifest error: {e}")
        print("Remove either 'count' or 'length' from the <data> element — they are mutually exclusive.")
    raise

Prevention

When it happens

Trigger: Triggered when dataNode.getAttribute('length') returns a non-empty string AND dataNode.getAttribute('count') also returns a non-empty string for the same <data> element. The code checks winlength first; if it's truthy, it then checks wincount, and if both are set, raises immediately.

Common situations: A developer editing the manifest adds a length attribute to a data element that already has a count attribute, or vice versa. A merge conflict resolution accidentally leaves both attributes. Copy-paste from another data element brings an extra attribute.

Related errors


AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10). Data as JSON: /api/errors/97147592040d5fd5. Report an issue: GitHub.