{"record":{"id":"306037d84a0cb382","repo":"abpframework/abp","slug":"given-module-instance-instance-gettype-assembl","errorCode":null,"errorMessage":"Given module instance ({instance.GetType().AssemblyQualifiedName}) is not an instance of given module type: {type.AssemblyQualifiedName}","messagePattern":"Given module instance \\((.+?)\\) is not an instance of given module type: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.Core/Volo/Abp/Modularity/AbpModuleDescriptor.cs","lineNumber":35,"sourceCode":"    public IAbpModule Instance { get; }\n\n    public bool IsLoadedAsPlugIn { get; }\n\n    public IReadOnlyList<IAbpModuleDescriptor> Dependencies => _dependencies.ToImmutableList();\n    private readonly List<IAbpModuleDescriptor> _dependencies;\n\n    public AbpModuleDescriptor(\n        [NotNull] Type type,\n        [NotNull] IAbpModule instance,\n        bool isLoadedAsPlugIn)\n    {\n        Check.NotNull(type, nameof(type));\n        Check.NotNull(instance, nameof(instance));\n        AbpModule.CheckAbpModuleType(type);\n\n        if (!type.GetTypeInfo().IsAssignableFrom(instance.GetType()))\n        {\n            throw new ArgumentException($\"Given module instance ({instance.GetType().AssemblyQualifiedName}) is not an instance of given module type: {type.AssemblyQualifiedName}\");\n        }\n\n        Type = type;\n        Assembly = type.Assembly;\n        AllAssemblies = AbpModuleHelper.GetAllAssemblies(type);\n        Instance = instance;\n        IsLoadedAsPlugIn = isLoadedAsPlugIn;\n\n        _dependencies = new List<IAbpModuleDescriptor>();\n    }\n\n    public void AddDependency(IAbpModuleDescriptor descriptor)\n    {\n        _dependencies.AddIfNotContains(descriptor);\n    }\n\n    public override string ToString()\n    {","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/AbpModuleDescriptor.cs#L17-L53","documentation":"Thrown by the AbpModuleDescriptor constructor when the IAbpModule instance passed in is not assignable to the declared module Type. ABP asserts type identity of a module instance at descriptor-creation time. It is an ArgumentException reporting both type names.","triggerScenarios":"Constructing new AbpModuleDescriptor(type, instance, isLoadedAsPlugIn) where instance.GetType() is not assignable to type (a mismatch between the registered module type and the live instance).","commonSituations":"Two modules with similar names confused during refactoring, a plugin instance loaded from a different assembly version than the declared Type, or a hand-rolled module loader that pairs the wrong type+instance.","solutions":["Ensure the instance and the Type come from the same assembly/version; reload the plugin after rebuild.","Pass instance.GetType() as the type argument when you are unsure.","Check that no two modules share a name and get reordered by the loader.","If you maintain a custom loader, re-run AbpModule.CheckAbpModuleType and the IsAssignableFrom guard before building the descriptor."],"exampleFix":"// before\nvar descriptor = new AbpModuleDescriptor(typeof(WrongModule), instance, true);\n\n// after\nvar descriptor = new AbpModuleDescriptor(instance.GetType(), instance, true);","handlingStrategy":"validation","validationCode":"static bool InstanceMatchesType(Type type, IAbpModule instance)\n    => type.IsAssignableFrom(instance.GetType());\n\nif (!InstanceMatchesType(declaredType, instance))\n    throw new InvalidOperationException(\"instance/type mismatch\");","typeGuard":"static bool IsModuleOf(Type type, IAbpModule instance) => type.IsAssignableFrom(instance.GetType());","tryCatchPattern":"try { var d = new AbpModuleDescriptor(type, instance, true); }\ncatch (ArgumentException ex) { logger.LogError(ex, \"Module descriptor mismatch\"); }","preventionTips":["Pair instance and type from the same assembly/version.","Use instance.GetType() when unsure of the declared type.","Rebuild plugins after module renames."],"tags":["modularity","argument","type-system","plugins","abp-core"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}