dotnet/wpf · error · NotImplementedException

BindRegion is not implemented.

Error message

BindRegion is not implemented.

What it means

PackageFilter.BindRegion wraps a COM IFilter for a package part. The MSDN IFilter specification requires BindRegion to return E_NOTIMPL, so this managed adapter deliberately throws NotImplementedException(SR.FilterBindRegionNotImplemented). It is not a bug; the operation is permanently unimplemented for every caller.

Solutions

  1. Do not call BindRegion on PackageFilter; restructure code so positions are consumed via IFilter::GetChunk/GetText instead of region binding.
  2. Catch NotImplementedException and treat the result as E_NOTIMPL, exactly as a native IFilter consumer must.
  3. If region binding is required, use a native IFilter implementation rather than PackageFilter.

Example fix

// before
var riid = Guid.NewGuid();
var ptr = filter.BindRegion(origPos, ref riid);
// after
// BindRegion is specified as E_NOTIMPL; avoid the call
// consume chunks/text instead:
// while (filter.GetChunk(...) == ... ) { filter.GetText(...); }
Defensive patterns

Strategy: try-catch

Try / catch

try { filter.BindRegion(origPos, ref riid); }
catch (NotImplementedException)
{
    // E_NOTIMPL per IFilter spec — skip region binding, use GetChunk/GetText
}

Prevention

When it happens

Trigger: Calling PackageFilter.BindRegion(FILTERREGION, ref Guid) directly, or routing through the IFilter interface of PackageFilter (e.g. when a Windows Search / indexing pipeline attempts to bind a region of the filtered document).

Common situations: Code that implements or consumes IFilter plumbing (custom search/indexing over XPS/OPC packages) calls BindRegion to map text offsets to monikers; any such call against PackageFilter fails by design on all .NET/WPF versions.

Related errors


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/PackageFilter.cs:258

            {
                throw new COMException(SR.FilterGetValueNotSupported,
                    (int)FilterErrorCode.FILTER_E_NO_VALUES);
            }

            return _currentFilter.GetValue();
        }

        /// <summary>
        /// BindRegion
        /// </summary>
        /// <param name="origPos"></param>
        /// <param name="riid"></param>
        /// <remarks>
        /// The MSDN specification requires this function to return E_NOTIMPL for the time being.
        /// </remarks>
        public IntPtr BindRegion(FILTERREGION origPos, ref Guid riid)
        {
            throw new NotImplementedException(SR.FilterBindRegionNotImplemented);
        }

        #endregion IFilter methods

        #region Private methods
        /// <summary>
        /// Find a filter object given its CLSID.
        /// </summary>
        /// <remarks>
        /// <para>
        /// If the clsid is not a proper IFilter clsid, this function will return null.
        /// The caller will then ignore the current part and attempt to filter the next part.
        /// </para>
        /// <para>
        /// Non-fatal exceptions from external filters, identified for all practical purposes
        /// with InvalidCastException, COMException and IOException, are `swallowed by this method.
        /// </para>
        /// </remarks>

View on GitHub (pinned to 81131a70a4)