{"record":{"id":"17942f2f227f5b1d","repo":"dotnet/wpf","slug":"0x80040202","errorCode":"0x80040202","errorMessage":"SR.TextStore_CONNECT_E_CANNOTCONNECT","messagePattern":"SR\\.TextStore_CONNECT_E_CANNOTCONNECT","errorType":"error_code","errorClass":"COMException","httpStatus":null,"severity":"warning","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextStore.cs","lineNumber":78,"sourceCode":"\n        #endregion Constructors\n\n        //------------------------------------------------------\n        //\n        //  Methods - ITextStoreACP\n        //\n        //------------------------------------------------------\n\n        #region ITextStoreACP\n\n        // See msdn's ITextStoreACP documentation for a full description.\n        public void AdviseSink(ref Guid riid, object obj, UnsafeNativeMethods.AdviseFlags flags)\n        {\n            UnsafeNativeMethods.ITextStoreACPSink sink;\n\n            if (riid != UnsafeNativeMethods.IID_ITextStoreACPSink)\n            {\n                throw new COMException(SR.TextStore_CONNECT_E_CANNOTCONNECT, unchecked((int)0x80040202));\n            }\n\n            sink = obj as UnsafeNativeMethods.ITextStoreACPSink;\n            if (sink == null)\n            {\n                throw new COMException(SR.TextStore_E_NOINTERFACE, unchecked((int)0x80004002));\n            }\n\n            // It's legal to replace existing sink.\n            if (HasSink)\n            {\n                Marshal.ReleaseComObject(_sink);\n            }\n            else\n            {\n                // Start tracking window movement for _sink.\n                _textservicesHost.RegisterWinEventSink(this);\n            }","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextStore.cs#L60-L96","documentation":"TextStore implements the TSF (Text Services Framework) ITextStoreAnchor/ACP wrapper. Its ITextStoreAdviseSink.AdviseSink throws COMException 0x80040202 (CONNECT_E_CANNOTCONNECT) when the requested sink IID is not IID_ITextStoreACPSink, i.e. the caller (TSF manager) asked to advise a sink type this store does not support.","triggerScenarios":"The TSF/IME framework calling AdviseSink with riid other than IID_ITextStoreACPSink on the TextStore associated with a focused TextBox/RichTextBox during text input activation.","commonSituations":"IME (Input Method Editor) activation on Windows with a non-ACP TSF sink; third-party TSF add-ins or accessibility tools advising unsupported sinks; unusual focus changes during TSF negotiation.","solutions":["Ensure the app's text services state is healthy: unfocus/refocus the TextBox so TSF re-advises with the correct IID_ITextStoreACPSink","Disable/test without third-party TSF text service add-ins to identify a mismatched sink provider","Update Windows/IME packs; the failure is on the caller side (TSF), not usually fixable in app code","The HRESULT is returned to TSF which handles it; in app code catch/handle is generally not needed — treat as environmental"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// HRESULT returned to TSF; app-side:\ntry { inputManagerWork(); } catch (COMException ce) when (ce.ErrorCode == unchecked((int)0x80040202)) { RefocusTextControl(); }","preventionTips":["Keep third-party TSF add-ins updated or disabled when IME issues appear","Refocus text controls after focus anomalies","Test IME scenarios on target Windows versions"],"tags":["com","tsf","ime","wpf"],"backgroundTag":"unsupported-operation","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}