dotnet/wpf · error · ArgumentException
The type of this parameter does not support a required…
Error message
The type of this parameter does not support a required interface
What it means
Verify.TypeSupportsInterface throws ArgumentException when the runtime Type of a parameter does not implement the required interface (checked via type.GetInterface(interfaceType.Name)). It is a static contract guard used inside WPF to reject arguments whose concrete type lacks a needed interface.
Solutions
- Ensure the parameter's concrete type implements the required interface before passing it.
- Use the interface name from the call site / parameterName to identify the missing interface and add the implementation.
- If the type is external, write an adapter/wrapper class that implements the interface and forwards to it.
Example fix
// before
helper.SetValue(myCustomObject); // does not implement ISupportInitialize
// after
class MyCustomObject : ISupportInitialize { ... }
helper.SetValue(myCustomObject); Defensive patterns
Strategy: type-guard
Validate before calling
if (requiredInterface.IsInstanceOfType(argument)) { api.Call(argument); } Type guard
static bool Implements<TReq>(object o) => o is TReq; // or typeof(TReq).IsInstanceOfType(o)
Try / catch
try { api.Call(obj); }
catch (ArgumentException ex) when (ex.Message.Contains("interface")) { /* substitute compliant type */ } Prevention
- Declare parameters as the interface type (I.e. ISupportInitialize) so the compiler enforces the contract.
- Keep interface implementations intact when refactoring classes passed to WPF APIs.
- Add unit tests asserting required interfaces via typeof(T).IsAssignableFrom.
When it happens
Trigger: Passing an object whose Type does not implement interfaceType to a WPF API that calls Verify.TypeSupportsInterface (or directly calling Verify.TypeSupportsInterface with a mismatched type/interface pair).
Common situations: Refactors that drop an interface implementation from a class still passed to legacy APIs; reflection-based object construction producing a type that no longer satisfies the contract; wrong generic or custom substitute type used in tests.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- The parameter must implement interface
- SR.IncorrectLocatorPartType
- SR.Invalid_IInputElement
- SR.ITypeDataObject_Not_Implemented
- SR.Mismatched_RoutedEvent
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/89cbc1561383e3ab.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Standard/Verify.cs:257
[DebuggerStepThrough]
public static void BoundedDoubleInc(double lowerBoundInclusive, double value, double upperBoundInclusive, string message, string parameter)
{
if (value < lowerBoundInclusive || value > upperBoundInclusive)
{
throw new ArgumentException(message, parameter);
}
}
[DebuggerStepThrough]
public static void TypeSupportsInterface(Type type, Type interfaceType, string parameterName)
{
Assert.IsNeitherNullNorEmpty(parameterName);
Verify.IsNotNull(type, "type");
Verify.IsNotNull(interfaceType, "interfaceType");
if (type.GetInterface(interfaceType.Name) == null)
{
throw new ArgumentException("The type of this parameter does not support a required interface", parameterName);
}
}
[DebuggerStepThrough]
public static void FileExists(string filePath, string parameterName)
{
Verify.IsNeitherNullNorEmpty(filePath, parameterName);
if (!File.Exists(filePath))
{
throw new ArgumentException($"No file exists at \"{filePath}\"", parameterName);
}
}
[DebuggerStepThrough]
internal static void ImplementsInterface(object parameter, Type interfaceType, string parameterName)
{
Assert.IsNotNull(parameter);
Assert.IsNotNull(interfaceType);View on GitHub (pinned to 81131a70a4)