diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpServiceConvention.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpServiceConvention.cs index e3bd8790f9..ab2003a595 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpServiceConvention.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpServiceConvention.cs @@ -75,7 +75,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Conventions foreach (var controllerModel in application.Controllers) { var baseControllerTypes = controllerModel.ControllerType - .GetBaseClasses(typeof(Controller)) + .GetBaseClasses(typeof(Controller), includeObject: false) .Where(t => !t.IsAbstract) .ToArray(); if (baseControllerTypes.Length > 0) diff --git a/framework/src/Volo.Abp.Core/System/AbpTypeExtensions.cs b/framework/src/Volo.Abp.Core/System/AbpTypeExtensions.cs index 26bfed5de4..1cf60a2906 100644 --- a/framework/src/Volo.Abp.Core/System/AbpTypeExtensions.cs +++ b/framework/src/Volo.Abp.Core/System/AbpTypeExtensions.cs @@ -60,12 +60,13 @@ namespace System /// /// The type to get its base classes. /// A type to stop going to the deeper base classes. This type will be be included in the returned array - public static Type[] GetBaseClasses([NotNull] this Type type, Type stoppingType) + /// True, to include the standard type in the returned array. + public static Type[] GetBaseClasses([NotNull] this Type type, Type stoppingType, bool includeObject = true) { Check.NotNull(type, nameof(type)); var types = new List(); - AddTypeAndBaseTypesRecursively(types, type.BaseType, true, stoppingType); + AddTypeAndBaseTypesRecursively(types, type.BaseType, includeObject, stoppingType); return types.ToArray(); } @@ -75,7 +76,7 @@ namespace System bool includeObject, [CanBeNull] Type stoppingType = null) { - if (type == stoppingType) + if (type == null || type == stoppingType) { return; }