abpframework/abp · error · ArgumentException
Given module instance ({instance.GetType().AssemblyQualified
Error message
Given module instance ({instance.GetType().AssemblyQualifiedName}) is not an instance of given module type: {type.AssemblyQualifiedName} What it means
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.
Source
Thrown at framework/src/Volo.Abp.Core/Volo/Abp/Modularity/AbpModuleDescriptor.cs:35
public IAbpModule Instance { get; }
public bool IsLoadedAsPlugIn { get; }
public IReadOnlyList<IAbpModuleDescriptor> Dependencies => _dependencies.ToImmutableList();
private readonly List<IAbpModuleDescriptor> _dependencies;
public AbpModuleDescriptor(
[NotNull] Type type,
[NotNull] IAbpModule instance,
bool isLoadedAsPlugIn)
{
Check.NotNull(type, nameof(type));
Check.NotNull(instance, nameof(instance));
AbpModule.CheckAbpModuleType(type);
if (!type.GetTypeInfo().IsAssignableFrom(instance.GetType()))
{
throw new ArgumentException($"Given module instance ({instance.GetType().AssemblyQualifiedName}) is not an instance of given module type: {type.AssemblyQualifiedName}");
}
Type = type;
Assembly = type.Assembly;
AllAssemblies = AbpModuleHelper.GetAllAssemblies(type);
Instance = instance;
IsLoadedAsPlugIn = isLoadedAsPlugIn;
_dependencies = new List<IAbpModuleDescriptor>();
}
public void AddDependency(IAbpModuleDescriptor descriptor)
{
_dependencies.AddIfNotContains(descriptor);
}
public override string ToString()
{View on GitHub (pinned to 7ed43b1931)
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.
Example fix
// before var descriptor = new AbpModuleDescriptor(typeof(WrongModule), instance, true); // after var descriptor = new AbpModuleDescriptor(instance.GetType(), instance, true);
Defensive patterns
Strategy: validation
Validate before calling
static bool InstanceMatchesType(Type type, IAbpModule instance)
=> type.IsAssignableFrom(instance.GetType());
if (!InstanceMatchesType(declaredType, instance))
throw new InvalidOperationException("instance/type mismatch"); Type guard
static bool IsModuleOf(Type type, IAbpModule instance) => type.IsAssignableFrom(instance.GetType());
Try / catch
try { var d = new AbpModuleDescriptor(type, instance, true); }
catch (ArgumentException ex) { logger.LogError(ex, "Module descriptor mismatch"); } Prevention
- Pair instance and type from the same assembly/version.
- Use instance.GetType() when unsure of the declared type.
- Rebuild plugins after module renames.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Given type is not an ABP module: {moduleType.AssemblyQualifi
- Given type ({item.AssemblyQualifiedName}) should be instance
- Could not find a depended module {dependedModuleType.Assembl
- Could not get module types from assembly: {assembly.FullName
- Could not get module types from assembly: {assembly.FullName
AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13).
Data as JSON: /api/errors/306037d84a0cb382.
Report an issue: GitHub.