{"record":{"id":"e1731e64694c0b8a","repo":"dotnet/wpf","slug":"sr-textstore-nosink","errorCode":null,"errorMessage":"SR.TextStore_NoSink","messagePattern":"SR\\.TextStore_NoSink","errorType":"error_code","errorClass":"COMException","httpStatus":null,"severity":"warning","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextStore.cs","lineNumber":121,"sourceCode":"        {\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);\n\n            bool isReplayingIMEChanges =  (_replayingIMEChangeReentrancyCount > 0);\n\n            if (IsTracing)\n            {\n                IMECompositionTracer.Trace(this, IMECompositionTraceOp.BRequestLock,\n                                            \"f:\", flags,\n                                            \"lf:\", _lockFlags,\n                                            \"icr:\", _replayingIMEChangeReentrancyCount,\n                                            \"ric:\", isReplayingIMEChanges,\n                                            \"tcr:\", _textChangeReentrencyCount,\n                                            \"paf:\", _pendingAsyncLockFlags);\n                if (_replayingIMEChangeReentrancyCount != 0)\n                {\n                    IMECompositionTracer.Mark(new System.Diagnostics.StackTrace(true));","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextStore.cs#L103-L139","documentation":"RequestLock, part of the TSF ITextStoreACP contract, asks the sink for a document lock. If no sink has ever been advised (HasSink is false), the store throws COMException SR.TextStore_NoSink because there is no one to request the lock from. This indicates RequestLock was invoked without a preceding successful AdviseSink.","triggerScenarios":"TSF/IME calling RequestLock on the TextStore before (or after) the ITextStoreACPSink was advised/unadvised — e.g. lock request arriving during connection setup, after teardown, or when AdviseSink failed earlier (see CONNECT_E errors).","commonSituations":"IME composition starting before TSF finished advising the sink; focus races between window activation and text store registration; third-party TSF services making out-of-order calls.","solutions":["Ensure the text control is focused and TSF connection completed (AdviseSink succeeded) before input/IME activity; refocus the control to re-establish the sink","Delay or guard IME-dependent operations until the store has an active sink","Disable faulty third-party TSF/IME components that call RequestLock out of order","Environmental HRESULT to TSF; typically no app-level catch needed, but log it if IME input breaks"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { /* IME-driven path */ } catch (COMException ce) when (ce.Message.Contains(\"NoSink\") || (uint)ce.ErrorCode == 0xFFFFFFFF) { RefocusTextControl(); }","preventionTips":["Ensure AdviseSink completed before IME input begins","Refocus controls to re-establish TSF sink after failures","Guard composition-dependent code on window activation state"],"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"}