{"record":{"id":"4a33a4cae409408a","repo":"dotnet/wpf","slug":"sr-notsupported-stickynoteannotations","errorCode":null,"errorMessage":"SR.NotSupported","messagePattern":"SR\\.NotSupported","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/StickyNote/StickyNoteAnnotations.cs","lineNumber":957,"sourceCode":"\n                //fire trace event\n                EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnnotation, EventTrace.Event.RemoveAttachedSNEnd);\n            }\n            else\n            {\n                throw new ArgumentException(SR.InvalidValueSpecified, nameof(attachedAnnotation));\n            }\n        }\n\n        /// <summary>\n        /// Called when an AttachedAnnotation's attached anchor changes.\n        /// </summary>\n        /// <param name=\"attachedAnnotation\">The attached annotation after modification</param>\n        /// <param name=\"previousAttachedAnchor\">The attached anchor previously associated with the attached annotation.</param>\n        /// <param name=\"previousAttachmentLevel\">The previous attachment level of the attached annotation.</param>\n        void IAnnotationComponent.ModifyAttachedAnnotation(IAttachedAnnotation attachedAnnotation, object previousAttachedAnchor, AttachmentLevel previousAttachmentLevel)\n        {\n            throw new NotSupportedException(SR.NotSupported);\n        }\n\n        /// <summary>\n        /// Gets the attached annotations this component is representing.\n        /// </summary>\n        /// <returns>list of IAttachedAnnotation instances this component is representing</returns>\n        IList IAnnotationComponent.AttachedAnnotations\n        {\n            get\n            {\n                ArrayList annotations = new ArrayList(1);\n\n                if (_attachedAnnotation != null)\n                {\n                    annotations.Add(_attachedAnnotation);\n                }\n\n                return annotations;","sourceCodeStart":939,"sourceCodeEnd":975,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/StickyNote/StickyNoteAnnotations.cs#L939-L975","documentation":"StickyNoteControl's explicit IAnnotationComponent.ModifyAttachedAnnotation implementation deliberately throws NotSupportedException(SR.NotSupported). Modifications to attached annotations on a StickyNote arrive through a different internal path (anchor updates), so the interface method is intentionally unimplemented.","triggerScenarios":"Any call to IAnnotationComponent.ModifyAttachedAnnotation on a StickyNoteControl, e.g. from custom annotation framework code that drives components through the IAnnotationComponent contract.","commonSituations":"Custom AnnotationComponent code iterating all components and calling ModifyAttachedAnnotation uniformly, ported annotation code that assumed StickyNote supports the full IAnnotationComponent surface.","solutions":["Do not call ModifyAttachedAnnotation on StickyNoteControl; handle modifications via the annotation store / AnnotationService events instead.","Check the component type (if (component is StickyNoteControl)) and route modification differently.","Implement your own IAnnotationComponent for modify-capable annotation UIs.","Wrap interface-driven modification loops in try/catch (NotSupportedException) for components that declare it unsupported."],"exampleFix":"// before\n((IAnnotationComponent)stickyNote).ModifyAttachedAnnotation(aa, prevAnchor, prevLevel);\n// after\nif (stickyNote is IAnnotationComponent comp && !(stickyNote is StickyNoteControl))\n    comp.ModifyAttachedAnnotation(aa, prevAnchor, prevLevel);","handlingStrategy":"try-catch","validationCode":"bool modifiesSupported = !(component is StickyNoteControl);","typeGuard":"static bool SupportsModify(IAnnotationComponent c) => c is not StickyNoteControl;","tryCatchPattern":"try { component.ModifyAttachedAnnotation(aa, prevAnchor, prevLevel); }\ncatch (NotSupportedException) { /* StickyNote ignores modify; route via annotation store */ }","preventionTips":["Check the concrete component type before calling the modify method.","Route StickyNote modifications through the AnnotationService/store events.","Handle NotSupportedException defensively in any generic IAnnotationComponent driver code."],"tags":["wpf","annotations","notsupported"],"backgroundTag":"method-not-implemented","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"}