{"record":{"id":"aa81fdf7b93f5f14","repo":"dotnet/wpf","slug":"0x80040200","errorCode":"0x80040200","errorMessage":"SR.TextStore_CONNECT_E_NOCONNECTION","messagePattern":"SR\\.TextStore_CONNECT_E_NOCONNECTION","errorType":"error_code","errorClass":"COMException","httpStatus":null,"severity":"warning","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextStore.cs","lineNumber":106,"sourceCode":"            if (HasSink)\n            {\n                Marshal.ReleaseComObject(_sink);\n            }\n            else\n            {\n                // Start tracking window movement for _sink.\n                _textservicesHost.RegisterWinEventSink(this);\n            }\n\n            _sink = sink;\n        }\n\n        // See msdn's ITextStoreACP documentation for a full description.\n        public void UnadviseSink(object obj)\n        {\n            if (obj != _sink)\n            {\n                throw new COMException(SR.TextStore_CONNECT_E_NOCONNECTION, unchecked((int)0x80040200));\n            }\n\n            Marshal.ReleaseComObject(_sink);\n            _sink = null;\n\n            // We don't need to track window movement for this textstore any more.\n            // _sink was the only consumer.\n            _textservicesHost.UnregisterWinEventSink(this);\n        }\n\n        // See msdn's ITextStoreACP documentation for a full description.\n        public void RequestLock(UnsafeNativeMethods.LockFlags flags, out int hrSession)\n        {\n            if (!HasSink)\n                throw new COMException(SR.TextStore_NoSink);\n\n            if (flags == 0)\n                throw new COMException(SR.TextStore_BadLockFlags);","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextStore.cs#L88-L124","documentation":"UnadviseSink throws COMException 0x80040200 (CONNECT_E_NOCONNECTION) when the object passed does not match the currently registered sink (_sink). Per ITextStoreACP semantics, a client may only unadvise the exact sink it advised; unadvising an unknown connection is an error.","triggerScenarios":"TSF calling UnadviseSink with an object reference different from the one previously registered via AdviseSink — e.g. double-unadvise, unadvising after the store reset its sink, or two different TSF clients managing the same text store.","commonSituations":"TSF connection teardown races during focus changes; stale sink references after the control was recreated; third-party text services mishandling connection lifetime.","solutions":["Refocus the TextBox/RichTextBox to let WPF re-establish the TSF connection cleanly","Avoid destroying/recreating the text control while IME composition is active; dispose/rebuild in a stable focus state","Disable problematic third-party TSF services to test whether they cause mismatched unadvise calls","Environmental HRESULT returned to TSF; app code rarely needs handling beyond robust focus/dispose lifecycle"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { /* TSF teardown path */ } catch (COMException ce) when (ce.ErrorCode == unchecked((int)0x80040200)) { /* connection already gone; ignore or re-advise */ }","preventionTips":["Never destroy text controls during active IME composition","Maintain balanced advise/unadvise lifecycles","Isolate third-party TSF services when diagnosing"],"tags":["com","tsf","ime","wpf"],"backgroundTag":"invalid-state-transition","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"}