{"record":{"id":"88107cfd209a1229","repo":"stride3d/stride","slug":"unable-to-reach-the-notifylistitemclicked-internal-method","errorCode":null,"errorMessage":"Unable to reach the NotifyListItemClicked internal method from ListBox class.","messagePattern":"Unable to reach the NotifyListItemClicked internal method from ListBox class\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Core.Assets.Editor/View/Controls/EditableContentListBox.cs","lineNumber":134,"sourceCode":"        private static readonly MethodInfo NotifyListItemClickedMethod;\n\n        private readonly DataTemplate regularContentTemplate;\n        private readonly DataTemplateSelector regularContentTemplateSelector;\n\n        private readonly DataTemplate editContentTemplate;\n        private readonly DataTemplateSelector editContentTemplateSelector;\n\n        private bool mouseDown;\n\n        public static readonly DependencyProperty CanEditProperty = DependencyProperty.Register(\"CanEdit\", typeof(bool), typeof(EditableContentListBoxItem), new PropertyMetadata(true));\n\n        public static readonly DependencyProperty IsEditingProperty = DependencyProperty.Register(\"IsEditing\", typeof(bool), typeof(EditableContentListBoxItem), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, IsEditingPropertyChanged));\n\n        static EditableContentListBoxItem()\n        {\n            NotifyListItemClickedMethod = typeof(ListBox).GetMethod(\"NotifyListItemClicked\", BindingFlags.Instance | BindingFlags.NonPublic);\n            if (NotifyListItemClickedMethod == null)\n                throw new InvalidOperationException(\"Unable to reach the NotifyListItemClicked internal method from ListBox class.\");\n        }\n\n        internal EditableContentListBoxItem(\n            DataTemplate regularContentTemplate,\n            DataTemplateSelector regularContentTemplateSelector,\n            DataTemplate editContentTemplate,\n            DataTemplateSelector editContentTemplateSelector)\n        {\n            this.regularContentTemplate = regularContentTemplate;\n            this.regularContentTemplateSelector = regularContentTemplateSelector;\n            this.editContentTemplate = editContentTemplate;\n            this.editContentTemplateSelector = editContentTemplateSelector;\n        }\n\n        public bool IsEditing { get { return (bool)GetValue(IsEditingProperty); } set { SetValue(IsEditingProperty, value); } }\n\n        public bool CanEdit { get { return (bool)GetValue(CanEditProperty); } set { SetValue(CanEditProperty, value); } }\n","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Core.Assets.Editor/View/Controls/EditableContentListBox.cs#L116-L152","documentation":"EditableContentListBoxItem's static constructor reflects ListBox.NotifyListItemClicked (private instance method) once per type load. If the method cannot be found — different .NET/WPF runtime version where the internal was renamed or removed — it throws InvalidOperationException, since item click editing would silently break.","triggerScenarios":"First use of EditableContentListBoxItem (type initializer) on a runtime (e.g. .NET Core 3.x/5+ vs .NET Framework) where ListBox.NotifyListItemClicked does not exist or its signature changed.","commonSituations":"Migrating the editor from .NET Framework to .NET Core where WPF internals changed; running on a patched runtime with internal API differences; trimming/AOT stripping internals.","solutions":["Update the reflection lookup to the method name/signature present in the target runtime, or wrap in a cross-version resolver trying several names","Replace the internal-method invocation with public API: handle clicks via ListBoxItem.Selected / PreviewMouseLeftButtonDown yourself","Catch TypeInitializationException at startup and log typeof(ListBox) runtime version to diagnose"],"exampleFix":"// before\nNotifyListItemClickedMethod = typeof(ListBox).GetMethod(\"NotifyListItemClicked\", BindingFlags.Instance | BindingFlags.NonPublic);\nif (NotifyListItemClickedMethod == null)\n    throw new InvalidOperationException(\"Unable to reach ...\");\n// after\nNotifyListItemClickedMethod = typeof(ListBox).GetMethod(\"NotifyListItemClicked\", BindingFlags.Instance | BindingFlags.NonPublic)\n    ?? typeof(ListBox).GetMethod(\"NotifyListItemClicked\", BindingFlags.Instance | BindingFlags.Public);\nif (NotifyListItemClickedMethod == null)\n    NotifyListItemClickedMethod = null; // fall back to public click handling","handlingStrategy":"try-catch","validationCode":"var m = typeof(ListBox).GetMethod(\"NotifyListItemClicked\", BindingFlags.Instance | BindingFlags.NonPublic);\nif (m == null) log.Warn(\"ListBox.NotifyListItemClicked unavailable on this runtime; using fallback click handling\");","typeGuard":"static bool SupportsNotifyListItemClicked() => typeof(ListBox).GetMethod(\"NotifyListItemClicked\", BindingFlags.Instance | BindingFlags.NonPublic) != null;","tryCatchPattern":"try { InitializeListBoxInternals(); }\ncatch (TypeInitializationException ex) { log.Error(\"EditableContentListBoxItem static init failed\", ex); UsePublicClickHandling = true; }","preventionTips":["Test static-constructor reflection code on every target runtime (Framework vs Core)","Prefer public events (Selected/PreviewMouseLeftButtonDown) over WPF internals","Add a startup self-check before creating the list UI"],"tags":["wpf","reflection","runtime-compatibility"],"backgroundTag":"missing-dependency","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}