HandyOrg/HandyControl · 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 checks that a Type argument implements a required interface using type.GetInterface(interfaceType.Name). It throws ArgumentException when the type does not expose an interface with the given name. Both arguments must be non-null (they are verified first).
Solutions
- Implement the required interface on the type, or pass a different type that implements it
- Check beforehand with typeof(IRequired).IsAssignableFrom(type)
- Verify the interface name matches exactly — GetInterface matches by name
Example fix
// before
api.Check(typeof(MyClass), typeof(ICommand), "type"); // MyClass doesn't implement ICommand
// after
public class MyClass : ICommand { /* implement members */ }
// or guard:
if (typeof(ICommand).IsAssignableFrom(typeof(MyClass))) api.Check(typeof(MyClass), typeof(ICommand), "type"); Defensive patterns
Strategy: type-guard
Validate before calling
if (type == null) throw new ArgumentNullException(nameof(type));
if (!interfaceType.IsAssignableFrom(type)) throw new ArgumentException($"{type} does not implement {interfaceType}", nameof(type)); Type guard
bool Implements(Type t, Type i) => t != null && i != null && i.IsAssignableFrom(t);
Try / catch
try { api.Call(type); } catch (ArgumentException ex) when (ex.Message.Contains("required interface")) { /* fall back to a compatible type */ } Prevention
- Run interface conformance checks in unit tests after refactors
- Prefer typeof(Iface).IsAssignableFrom(type) checks at call sites
- Watch for renamed interfaces breaking name-based GetInterface lookups
When it happens
Trigger: Passing a concrete Type (e.g. typeof(MyClass)) to an API expecting an implementer of a specific interface (e.g. ICommand or IWindowChrome), where the class does not implement it.
Common situations: Refactoring renames an interface or drops an implementation; passing a base class that lacks the interface that derived classes implement; type confusion between similarly named interfaces.
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
- ExceptionStringTable.EventTriggerCannotFindEventNameExceptio…
- ExceptionStringTable.EventTriggerBaseInvalidEventExceptionMe…
AI-assisted analysis of HandyOrg/HandyControl@2c0875ebd6 (2026-09-14).
Data as JSON: /api/errors/9118a6a4e0b4e0e2.
Report an issue: GitHub.
Appendix: source
Thrown at src/Shared/Microsoft.Windows.Shell/Standard/Verify.cs:206
[DebuggerStepThrough]
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
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]
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static void TypeSupportsInterface(Type type, Type interfaceType, string parameterName)
{
Verify.IsNotNull<Type>(type, "type");
Verify.IsNotNull<Type>(interfaceType, "interfaceType");
if (type.GetInterface(interfaceType.Name) == null)
{
throw new ArgumentException("The type of this parameter does not support a required interface", parameterName);
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DebuggerStepThrough]
public static void FileExists(string filePath, string parameterName)
{
Verify.IsNeitherNullNorEmpty(filePath, parameterName);
if (!File.Exists(filePath))
{
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "No file exists at \"{0}\"", new object[]
{
filePath
}), parameterName);
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]View on GitHub (pinned to 2c0875ebd6)