{"record":{"id":"89cbc1561383e3ab","repo":"dotnet/wpf","slug":"the-type-of-this-parameter-does-not-support-a-required","errorCode":null,"errorMessage":"The type of this parameter does not support a required interface","messagePattern":"The type of this parameter does not support a required interface","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Standard/Verify.cs","lineNumber":257,"sourceCode":"        [DebuggerStepThrough]\n        public static void BoundedDoubleInc(double lowerBoundInclusive, double value, double upperBoundInclusive, string message, string parameter)\n        {\n            if (value < lowerBoundInclusive || value > upperBoundInclusive)\n            {\n                throw new ArgumentException(message, parameter);\n            }\n        }\n        \n        [DebuggerStepThrough]\n        public static void TypeSupportsInterface(Type type, Type interfaceType, string parameterName)\n        {\n            Assert.IsNeitherNullNorEmpty(parameterName);\n            Verify.IsNotNull(type, \"type\");\n            Verify.IsNotNull(interfaceType, \"interfaceType\");\n\n            if (type.GetInterface(interfaceType.Name) == null)\n            {\n                throw new ArgumentException(\"The type of this parameter does not support a required interface\", parameterName);\n            }\n        }\n        \n        [DebuggerStepThrough]\n        public static void FileExists(string filePath, string parameterName)\n        {\n            Verify.IsNeitherNullNorEmpty(filePath, parameterName);\n            if (!File.Exists(filePath))\n            {\n                throw new ArgumentException($\"No file exists at \\\"{filePath}\\\"\", parameterName);\n            }\n        }\n        \n        [DebuggerStepThrough]\n        internal static void ImplementsInterface(object parameter, Type interfaceType, string parameterName)\n        {\n            Assert.IsNotNull(parameter);\n            Assert.IsNotNull(interfaceType);","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Standard/Verify.cs#L239-L275","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nhelper.SetValue(myCustomObject); // does not implement ISupportInitialize\n// after\nclass MyCustomObject : ISupportInitialize { ... }\nhelper.SetValue(myCustomObject);","handlingStrategy":"type-guard","validationCode":"if (requiredInterface.IsInstanceOfType(argument)) { api.Call(argument); }","typeGuard":"static bool Implements<TReq>(object o) => o is TReq; // or typeof(TReq).IsInstanceOfType(o)","tryCatchPattern":"try { api.Call(obj); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"interface\")) { /* substitute compliant type */ }","preventionTips":["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."],"tags":["type-mismatch","interface","wpf","argument-validation"],"backgroundTag":"type-mismatch","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"}