dotnet/wpf · info · COMException

FILTER_E_END_OF_CHUNKS

FILTER_E_END_OF_CHUNKS

Error message

Filter has no more chunks to return.

What it means

The COM IFilter protocol signals normal end of enumeration with the HRESULT FILTER_E_END_OF_CHUNKS. WPF's IndexingFilterMarshaler surfaces this either as a COMException with that code (when ThrowOnEndOfChunks is true) or as an empty STAT_CHUNK sentinel. It is expected control flow, not a filter failure — the document's chunks are simply exhausted.

Solutions

  1. Treat this COMException as normal end-of-enumeration: catch it (matching the FILTER_E_END_OF_CHUNKS HResult) and break out of the loop
  2. Set ThrowOnEndOfChunks = false so GetChunk returns an empty STAT_CHUNK sentinel instead of throwing
  3. Structure the enumeration as a try/catch loop that terminates on this specific HResult rather than treating it as an error

Example fix

// before: unbounded loop crashes at end of document
while (true)
{
    var chunk = filter.GetChunk();
    Process(chunk);
}

// after: stop on the end-of-chunks signal
while (true)
{
    try
    {
        var chunk = filter.GetChunk();
        Process(chunk);
    }
    catch (COMException ex) when (ex.HResult == (int)FilterErrorCode.FILTER_E_END_OF_CHUNKS)
    {
        break; // normal end of enumeration
    }
}
Defensive patterns

Strategy: try-catch

Try / catch

try
{
    var chunk = filter.GetChunk();
    Process(chunk);
}
catch (COMException ex) when (ex.HResult == (int)FilterErrorCode.FILTER_E_END_OF_CHUNKS)
{
    // expected end of enumeration — exit the loop, not an error
}

Prevention

When it happens

Trigger: A search host calls GetChunk after all chunks of the document have already been returned while ThrowOnEndOfChunks is true.

Common situations: Indexing loops that keep calling GetChunk without stopping on the end-of-chunks signal; test harnesses exercising WPF's IFilter wrapper for XPS documents; hosts ported from filters that return different termination sentinels.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/7007d53bdf87dea1. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/indexingfiltermarshaler.cs:273

        }

        /// <summary>
        /// GetChunk
        /// </summary>
        /// <returns>the next chunk</returns>
        public STAT_CHUNK GetChunk()
        {
            // Get the managed chunk
            ManagedChunk managedChunk = _implementation.GetChunk();

            if (managedChunk == null)
            {
                // End of chunks.

                if (ThrowOnEndOfChunks)
                {
                    // Throw exception.
                    throw new COMException(SR.FilterEndOfChunks,
                        (int)FilterErrorCode.FILTER_E_END_OF_CHUNKS);
                }

                // Return STAT_CHUNK with idChunk as 0.

                STAT_CHUNK chunk = new STAT_CHUNK
                {
                    idChunk = 0
                };
                return chunk;
}

            // Valid chunk. Return corresponding STAT_CHUNK.
            return MarshalChunk(managedChunk);
        }

        /// <summary>
        ///    GetText

View on GitHub (pinned to 81131a70a4)