{"record":{"id":"baddc850516c8f86","repo":"stride3d/stride","slug":"the-behaviorsproperty-static-field-is-missing-on-the-class","errorCode":null,"errorMessage":"The BehaviorsProperty static field is missing on the class Microsoft.Xaml.Behaviors. This version of the assembly is not supported.","messagePattern":"The BehaviorsProperty static field is missing on the class Microsoft\\.Xaml\\.Behaviors\\. This version of the assembly is not supported\\.","errorType":"exception","errorClass":"MissingFieldException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Core.Assets.Editor/View/Behaviors/DragDrop/DragDropAdornerManager.cs","lineNumber":52,"sourceCode":"        private static InsertAdorner insertAdorner;\n        private static AdornerLayer currentLayer;\n        private static HighlightBorderAdorner dropTargetAdorner;\n        private static AdornerLayer dropTargetLayer;\n        private static DisplayDropAdorner dataType;\n\n        private static readonly Dictionary<FrameworkElement, Window> ElementToWindowLookup = new Dictionary<FrameworkElement, Window>();\n        private static readonly Dictionary<Window, HashSet<FrameworkElement>> WindowToElementsLookup = new Dictionary<Window, HashSet<FrameworkElement>>();\n\n        static DragDropAdornerManager()\n        {\n            // We use a timer to deactivate the adorners, because the DragLeave event is broken and unusable.\n            // OnDragOver is called constantly (seems to be once per frame) so it is more or less safe to work with timers.\n            DragLeaveTimer.Timeout += (s, e) => Deactivate();\n            // Interaction.cs via DotPeek: \"This property is not exposed publicly. This forces clients to use the GetBehaviors [...] ensuring the collection exists\"\n            // There is no public way to get the BehaviorCollection only if it exists, without creating it if it does not.\n            var behaviorsPropertyFieldInfo = typeof(Interaction).GetField(\"BehaviorsProperty\", BindingFlags.NonPublic | BindingFlags.Static);\n            if (behaviorsPropertyFieldInfo == null)\n                throw new MissingFieldException(\"The BehaviorsProperty static field is missing on the class Microsoft.Xaml.Behaviors. This version of the assembly is not supported.\");\n\n            BehaviorsProperty = (DependencyProperty)behaviorsPropertyFieldInfo.GetValue(null);\n        }\n\n        /// <summary>\n        /// Updates the state of the adorner associated to the given <see cref=\"FrameworkElement\"/>.\n        /// </summary>\n        /// <param name=\"element\">The element that is associated to the adorner to update.</param>\n        /// <param name=\"adornerState\">The new state to set.</param>\n        internal static void SetAdornerState([NotNull] FrameworkElement element, HighlightAdornerState adornerState)\n        {\n            var adornerLayer = AdornerLayer.GetAdornerLayer(element);\n            if (adornerLayer != null)\n            {\n                Tuple<AdornerLayer, HighlightBorderAdorner> adorner;\n                if (DropAdorners.TryGetValue(element, out adorner))\n                    adorner.Item2.State = adornerState;\n            }","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Core.Assets.Editor/View/Behaviors/DragDrop/DragDropAdornerManager.cs#L34-L70","documentation":"At startup, DragDropAdornerManager reflects over Microsoft.Xaml.Behaviors' Interaction class to grab its private static BehaviorsProperty field. If reflection returns null, the loaded version of the assembly does not have that private field, so the manager throws MissingFieldException because drag-drop adorner behavior cannot work against this assembly version.","triggerScenarios":"Constructing DragDropAdornerManager (or first drag-over in the asset editor) when the referenced Microsoft.Xaml.Behaviors assembly version differs from the one the code was written against (renamed/moved private static field).","commonSituations":"NuGet package upgrade of Microsoft.Xaml.Behaviors.Wpf to a version where internal layout changed; binding to an older/newer assembly at runtime via binding redirects; mixing Stride editor with a different behaviors package.","solutions":["Pin Microsoft.Xaml.Behaviors.Wpf to the exact version the Stride editor was built against in packages.config/PackageReference","Check binding redirects in app.config so the expected assembly version is actually loaded","Reflect at startup (in a try/catch or version check) and log typeof(Interaction).Assembly.Location to diagnose which assembly is loaded","If the field was renamed upstream, update the reflection string or reimplement the behavior collection lookup without reflection"],"exampleFix":"// before\nvar behaviorsPropertyFieldInfo = typeof(Interaction).GetField(\"BehaviorsProperty\", BindingFlags.NonPublic | BindingFlags.Static);\nif (behaviorsPropertyFieldInfo == null)\n    throw new MissingFieldException(\"...not supported.\");\n// after\n<PackageReference Include=\"Microsoft.Xaml.Behaviors.Wpf\" Version=\"1.1.31\" /> <!-- pinned to supported version -->","handlingStrategy":"validation","validationCode":"var field = typeof(Interaction).GetField(\"BehaviorsProperty\", BindingFlags.NonPublic | BindingFlags.Static);\nif (field == null) throw new NotSupportedException($\"Unsupported Microsoft.Xaml.Behaviors version: {typeof(Interaction).Assembly.FullName}\");","typeGuard":"static bool IsSupportedBehaviorsVersion() => typeof(Interaction).GetField(\"BehaviorsProperty\", BindingFlags.NonPublic | BindingFlags.Static) != null;","tryCatchPattern":"try { adornerManager = new DragDropAdornerManager(...); }\ncatch (MissingFieldException ex) { log.Error(\"Incompatible Microsoft.Xaml.Behaviors assembly\", ex); DisableDragDropAdorners(); }","preventionTips":["Pin the exact Microsoft.Xaml.Behaviors.Wpf package version in your build","Add a startup smoke test that runs the reflection lookup before UI loads","Log typeof(Interaction).Assembly.Location at startup for diagnosis"],"tags":["wpf","reflection","assembly-version"],"backgroundTag":"unsupported-dependency-version","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"}