dotnet/wpf · warning · COMException

0x80004002

0x80004002

Error message

SR.TextStore_E_NOINTERFACE

What it means

In AdviseSink, after the IID check passes, the object is cast to UnsafeNativeMethods.ITextStoreACPSink; if the cast fails the store throws COMException 0x80004002 (E_NOINTERFACE). The advising object claims the IID but does not actually implement the ACP sink interface.

Solutions

  1. Refocus the text control or restart the app to force a fresh TSF advise cycle
  2. Identify and disable/remove the offending TSF text service or IME add-in
  3. Update Windows/IME to a version whose TSF provider correctly implements ITextStoreACPSink
  4. Environmental on the caller side; app code typically lets the HRESULT propagate to TSF rather than handling it
Defensive patterns

Strategy: retry

Try / catch

try { /* text input path */ } catch (COMException ce) when (ce.ErrorCode == unchecked((int)0x80004002)) { RestartTextServicesOrRefocus(); }

Prevention

When it happens

Trigger: TSF calling AdviseSink with the correct IID_ITextStoreACPSink but passing an object that does not implement ITextStoreACPSink (queried interface failed on the caller side) during text store connection for a focused text box.

Common situations: Faulty TSF text service / IME add-ins with broken QueryInterface; corrupted input service state; mismatched Windows text framework versions.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextStore.cs:84

        //
        //------------------------------------------------------

        #region ITextStoreACP

        // See msdn's ITextStoreACP documentation for a full description.
        public void AdviseSink(ref Guid riid, object obj, UnsafeNativeMethods.AdviseFlags flags)
        {
            UnsafeNativeMethods.ITextStoreACPSink sink;

            if (riid != UnsafeNativeMethods.IID_ITextStoreACPSink)
            {
                throw new COMException(SR.TextStore_CONNECT_E_CANNOTCONNECT, unchecked((int)0x80040202));
            }

            sink = obj as UnsafeNativeMethods.ITextStoreACPSink;
            if (sink == null)
            {
                throw new COMException(SR.TextStore_E_NOINTERFACE, unchecked((int)0x80004002));
            }

            // It's legal to replace existing sink.
            if (HasSink)
            {
                Marshal.ReleaseComObject(_sink);
            }
            else
            {
                // Start tracking window movement for _sink.
                _textservicesHost.RegisterWinEventSink(this);
            }

            _sink = sink;
        }

        // See msdn's ITextStoreACP documentation for a full description.
        public void UnadviseSink(object obj)

View on GitHub (pinned to 81131a70a4)