{"record":{"id":"4ea2bf11bded2008","repo":"abpframework/abp","slug":"parametername-type-of-type-assemblyqualifiedna","errorCode":null,"errorMessage":"{parameterName} (type of {type.AssemblyQualifiedName}) should be assignable to the {typeof(TBaseType).GetFullNameWithAssemblyName()}!","messagePattern":"(.+?) \\(type of (.+?)\\) should be assignable to the (.+?)!","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.Core/Volo/Abp/Check.cs","lineNumber":135,"sourceCode":"    {\n        if (value == null || value.Count <= 0)\n        {\n            throw new ArgumentException(parameterName + \" can not be null or empty!\", parameterName);\n        }\n\n        return value;\n    }\n\n    [ContractAnnotation(\"type:null => halt\")]\n    public static Type AssignableTo<TBaseType>(\n        Type type,\n        [InvokerParameterName][NotNull] string parameterName)\n    {\n        NotNull(type, parameterName);\n\n        if (!type.IsAssignableTo<TBaseType>())\n        {\n            throw new ArgumentException($\"{parameterName} (type of {type.AssemblyQualifiedName}) should be assignable to the {typeof(TBaseType).GetFullNameWithAssemblyName()}!\");\n        }\n\n        return type;\n    }\n\n    public static string? Length(\n        string? value,\n        [InvokerParameterName][NotNull] string parameterName,\n        int maxLength,\n        int minLength = 0)\n    {\n        if (minLength > 0)\n        {\n            if (string.IsNullOrEmpty(value))\n            {\n                throw new ArgumentException(parameterName + \" can not be null or empty!\", parameterName);\n            }\n","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Core/Volo/Abp/Check.cs#L117-L153","documentation":"Thrown by Check.AssignableTo<TBaseType>(Type, string) when the supplied type is not assignable to TBaseType (i.e. it neither is, nor implements/derives from, the expected base type). The message includes both the offending type's AssemblyQualifiedName and the expected type's full name so mismatches are obvious.","triggerScenarios":"Calling Check.AssignableTo<IMyService>(concreteType, nameof(concreteType)) where concreteType does not implement IMyService. Common in ABP module/contributor code that reflects over assemblies or plugin types, and in typed registration helpers that must verify a candidate type fits a contract.","commonSituations":"Registering a plugin/convention type that was refactored and lost an interface; passing a base type where a derived type is required; version skew where an assembly was swapped and a type no longer implements the expected interface; wrong generic argument inferred by the compiler.","solutions":["Compare the two type names in the exception message: make the offending type implement or derive from the expected base type.","Verify the assembly actually loaded is the one you compiled against (check the AssemblyQualifiedName, not just the FullName) to catch version/redirect mismatches.","If multiple candidates are possible, use typeof(...) explicitly as the generic argument rather than relying on inference.","Add a unit test asserting type.IsAssignableTo<TBaseType>() to catch regressions after refactors."],"exampleFix":"// before\npublic class MyHandler { } // missing interface\nCheck.AssignableTo<IEventHandler>(typeof(MyHandler), nameof(handlerType));\n\n// after\npublic class MyHandler : IEventHandler { }\nCheck.AssignableTo<IEventHandler>(typeof(MyHandler), nameof(handlerType));","handlingStrategy":"type-guard","validationCode":"// Verify assignability before calling Check.AssignableTo\nif (!typeof(MyHandler).IsAssignableTo<IEventHandler>())\n    throw new InvalidOperationException($\"{typeof(MyHandler)} is not an IEventHandler\");","typeGuard":"static bool IsA<TBase>(Type t) => t.IsAssignableTo<TBase>();\n// usage: if (IsA<IEventHandler>(candidateType)) { ... }","tryCatchPattern":null,"preventionTips":["Add a unit test asserting candidateType.IsAssignableTo<TBase>() for every convention-registered type.","Pin plugin assemblies with a test that loads them and checks assignability, to catch version skew.","Prefer explicit typeof(...) generic arguments over inference when registering reflected types."],"tags":["argument-validation","reflection","typesystem","abp","guard-clause"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}