abpframework/abp · error · CliUsageException
There are multiple classes derived from AbpModule in the pro
Error message
There are multiple classes derived from AbpModule in the project {projectFile}: {moduleFiles} What it means
Symmetric to 208: ModuleClassFinder.Find returns more than one AbpModule-derived class in the project, so the CLI cannot decide which one should receive the [DependsOn] attribute. It throws a CliUsageException enumerating the ambiguous candidate files to surface the conflict.
Source
Thrown at framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/ProjectNugetPackageAdder.cs:280
if (useDotnetCliToInstall)
{
await AddUsingDotnetCli(package, version);
}
else
{
await AddToCsprojManuallyAsync(projectFile, package, version);
}
var moduleFiles = ModuleClassFinder.Find(projectFile, "AbpModule");
if (moduleFiles.Count == 0)
{
throw new CliUsageException(
$"Could not find a class derived from AbpModule in the project {projectFile}");
}
if (moduleFiles.Count > 1)
{
throw new CliUsageException(
$"There are multiple classes derived from AbpModule in the project {projectFile}: " +
moduleFiles.JoinAsString(", "));
}
ModuleClassDependcyAdder.Add(moduleFiles.First(), package.ModuleClass);
}
if (useDotnetCliToInstall && (package.Target == NuGetPackageTarget.Blazor ||
package.Target == NuGetPackageTarget.BlazorServer ||
package.Target == NuGetPackageTarget.BlazorWebAssembly))
{
try
{
await RunBundleForBlazorAsync(projectFile);
}
catch (Exception)
{
Logger.LogWarning("Couldn't run bundle for blazor.");View on GitHub (pinned to 7ed43b1931)
Solutions
- Remove or rename the stale module class so only one AbpModule-derived class remains in the project.
- If multiple modules are intentional, add the [DependsOn] manually to the correct one and skip the auto-wiring command.
- Run 'abp add-package' targeting a more specific project that has a single module class via --project.
Example fix
// before: two AbpModule classes in one project
public class OldModule : AbpModule { }
public class MyProjectModule : AbpModule { }
// after
// (delete OldModule.cs)
public class MyProjectModule : AbpModule { } Defensive patterns
Strategy: validation
Validate before calling
var modules = ModuleClassFinder.Find(projectFile, "AbpModule");
if (modules.Count > 1)
{ Console.Error.WriteLine($"Multiple module classes found: {modules.JoinAsString(", ")}"); return; } Prevention
- Delete stale module files after renames so only one module class remains.
- Add [DependsOn] manually when a project legitimately has multiple module classes.
When it happens
Trigger: Adding a package to a project that legitimately has multiple module classes (e.g. a module split into host + child modules), or one where an old module class was not deleted after a rename, producing duplicates that both inherit AbpModule.
Common situations: Refactoring that left a stale module file; a project that intentionally defines several module classes (rare but valid); copy-paste creating a duplicate class declaration.
Related errors
- Could not find a class derived from AbpModule in the project
- Couldn't find any project/solution.
- '{packageName}' nuget package could not be found!
- Package is not found or downloadable!
- "public class" declaration not found!
AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13).
Data as JSON: /api/errors/f1a82b2aebac5aed.
Report an issue: GitHub.