{"record":{"id":"8beb348ed7e72000","repo":"dotnet/wpf","slug":"sr-gesturerecognizernotavailable","errorCode":null,"errorMessage":"SR.GestureRecognizerNotAvailable","messagePattern":"SR\\.GestureRecognizerNotAvailable","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/GestureRecognizer.cs","lineNumber":250,"sourceCode":"\n            _disposed = true;\n        }\n\n        #endregion IDisposable\n\n        //-------------------------------------------------------------------------------\n        //\n        // Private Methods\n        //\n        //-------------------------------------------------------------------------------\n\n        #region Private Methods\n        //verify that there is a recognizer available, throw if not\n        private void VerifyRecognizerAvailable()\n        {\n            if (_nativeRecognizer == null)\n            {\n                throw new InvalidOperationException(SR.GestureRecognizerNotAvailable);\n            }\n        }\n        \n        // Verify whether this object has been disposed.\n        private void VerifyDisposed()\n        {\n            ObjectDisposedException.ThrowIf(_disposed, typeof(GestureRecognizer));\n        }\n\n        #endregion Private Methods\n\n        //-------------------------------------------------------------------------------\n        //\n        // Private Fields\n        //\n        //-------------------------------------------------------------------------------\n\n        #region Private Fields","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/GestureRecognizer.cs#L232-L268","documentation":"GestureRecognizer throws InvalidOperationException when no native gesture recognizer is available (_nativeRecognizer == null). On platforms or configurations without ink/gesture recognition support (e.g. non-Windows, or missing tablet/ink runtime components), the recognizer cannot function.","triggerScenarios":"Calling SetEnabledGestures, GetEnabledGestures, or Recognize when the native recognizer failed to initialize — typically on systems lacking Ink recognition (no Windows ink components / wrong OS).","commonSituations":"Running WPF ink tests on CI without ink support; deployment to Windows SKUs without the gesture recognizer; cross-platform or service contexts (no STA/presentation context).","solutions":["Check GestureRecognizer availability before use (e.g. try/catch InvalidOperationException or probe via ApplicationGesture support)","Ensure the app runs on Windows with ink/gesture recognition components installed","Wrap recognition in try-catch and degrade gracefully (skip gesture recognition) when unavailable"],"exampleFix":"// before\nvar results = recognizer.Recognize(stroke);\n// after\ntry { var results = recognizer.Recognize(stroke); }\ncatch (InvalidOperationException) { /* recognizer not available on this machine */ }","handlingStrategy":"try-catch","validationCode":"// availability must be probed at runtime\nbool recognizerAvailable = IsGestureRecognizerPresent(); // e.g. wrap first use in try/catch","typeGuard":"bool RecognizerUsable(GestureRecognizer g) { try { g.GetEnabledGestures(); return true; } catch (InvalidOperationException) { return false; } }","tryCatchPattern":"try { results = recognizer.Recognize(strokes); } catch (InvalidOperationException) when (IsNativeRecognizerMissing()) { /* feature unavailable on this machine */ }","preventionTips":["Feature-detect gesture recognition at app startup and hide the feature when missing","Run on Windows SKUs with ink recognition components","Provide a non-gesture fallback for ink interaction"],"tags":["wpf","ink","invalidoperationexception","platform-support","gesture-recognition"],"backgroundTag":"unsupported-platform","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}