{"record":{"id":"3001b517c30937bc","repo":"dotnet/wpf","slug":"sr-dragdrop-dragdropeffectsinvalid","errorCode":null,"errorMessage":"SR.DragDrop_DragDropEffectsInvalid","messagePattern":"SR\\.DragDrop_DragDropEffectsInvalid","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/DragEventArgs.cs","lineNumber":147,"sourceCode":"                return _allowedEffects;\n            }\n        }\n\n        /// <summary>\n        /// The effects of drag and drop operation\n        /// </summary>\n        public DragDropEffects Effects\n        {\n            get\n            {\n                return _effects;\n            }\n\n            set\n            {\n                if (!DragDrop.IsValidDragDropEffects(value))\n                {\n                    throw new ArgumentException(SR.Format(SR.DragDrop_DragDropEffectsInvalid, \"value\"));\n                }\n\n                _effects = value;\n            }\n        }\n\n        #endregion Public Properties\n\n        #region Protected Methods\n\n        //------------------------------------------------------\n        //\n        //  Protected Methods\n        //\n        //------------------------------------------------------\n\n        /// <summary>\n        /// The mechanism used to call the type-specific handler on the target.","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/DragEventArgs.cs#L129-L165","documentation":"The DragEventArgs.Effects setter validates the value with DragDrop.IsValidDragDropEffects and throws ArgumentException (\"'value' DragDropEffects is not valid.\") for values outside the defined DragDropEffects flags set. This protects the drag-and-drop feedback protocol from meaningless effect combinations.","triggerScenarios":"Assigning e.Effects (or a DragEventArgs.Effects property) to an int-cast or computed value that is not a valid DragDropEffects bit combination, e.g. (DragDropEffects)0x100 or an invalid cast of another enum.","commonSituations":"Casting integers or foreign enums into DragDropEffects in drag event handlers; data-binding Effects to a property of the wrong enum type; copy-pasted code using System.Windows.Forms DragDropEffects values incorrectly.","solutions":["Only assign values built from the WPF DragDropEffects flags (None, Copy, Move, Scroll, All, Link) or valid combinations thereof.","Validate arbitrary values with DragDrop.IsValidDragDropEffects before assigning.","Check for name collisions with System.Windows.Forms.DragDropEffects and ensure the correct using/namespace is referenced."],"exampleFix":"// before\ne.Effects = (DragDropEffects)myIntValue; // may be invalid\n// after\nvar fx = (DragDropEffects)myIntValue;\nif (DragDrop.IsValidDragDropEffects(fx))\n    e.Effects = fx;\nelse\n    e.Effects = DragDropEffects.None;","handlingStrategy":"validation","validationCode":"static bool IsValidEffects(DragDropEffects fx) => System.Windows.DragDrop.IsValidDragDropEffects(fx);","typeGuard":"static bool IsWpfDragDropEffects(Enum value) => value is System.Windows.DragDropEffects;","tryCatchPattern":"try { e.Effects = effects; }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"DragDropEffects\")) { e.Effects = System.Windows.DragDropEffects.None; }","preventionTips":["Fully qualify DragDropEffects to avoid WinForms/WPF enum collisions.","Never cast raw ints to DragDropEffects; build values from named flags.","Validate computed values with DragDrop.IsValidDragDropEffects before assignment."],"tags":["wpf","drag-drop","enum","argument-exception"],"backgroundTag":"invalid-enum-value","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"}