dotnet/wpf · error · ArgumentException
SR.DragDrop_DragDropEffectsInvalid
Error message
SR.DragDrop_DragDropEffectsInvalid
What it means
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.
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.
Example fix
// before
e.Effects = (DragDropEffects)myIntValue; // may be invalid
// after
var fx = (DragDropEffects)myIntValue;
if (DragDrop.IsValidDragDropEffects(fx))
e.Effects = fx;
else
e.Effects = DragDropEffects.None; Defensive patterns
Strategy: validation
Validate before calling
static bool IsValidEffects(DragDropEffects fx) => System.Windows.DragDrop.IsValidDragDropEffects(fx);
Type guard
static bool IsWpfDragDropEffects(Enum value) => value is System.Windows.DragDropEffects;
Try / catch
try { e.Effects = effects; }
catch (ArgumentException ex) when (ex.Message.Contains("DragDropEffects")) { e.Effects = System.Windows.DragDropEffects.None; } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- InvalidEnumArgumentException(value, (int) value…
- is not a valid OS!
- SR.Animation_UnrecognizedHandoffBehavior
- SR.Animation_UnrecognizedHandoffBehavior
- SR.Format(SR.InputScope_InvalidInputScopeName, "value")
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/3001b517c30937bc.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/DragEventArgs.cs:147
return _allowedEffects;
}
}
/// <summary>
/// The effects of drag and drop operation
/// </summary>
public DragDropEffects Effects
{
get
{
return _effects;
}
set
{
if (!DragDrop.IsValidDragDropEffects(value))
{
throw new ArgumentException(SR.Format(SR.DragDrop_DragDropEffectsInvalid, "value"));
}
_effects = value;
}
}
#endregion Public Properties
#region Protected Methods
//------------------------------------------------------
//
// Protected Methods
//
//------------------------------------------------------
/// <summary>
/// The mechanism used to call the type-specific handler on the target.View on GitHub (pinned to 81131a70a4)