Open Closed

Additional "Managers" in AppServiceBase.cs #10489

hostmaster created


We're upgrading our AspNetZero 6.2 to 10.3.0, using Angular with .Net Core 5.0.

Looking through the xxxAppServiceBase.cs in the .Application project, we know there was a TenantManager and UserManager, and it seemed like a great way to add additional Managers for other core arreas of the system, so we added other Managers for other parts of the system, eg,

public ProductManager ProductManager {get;set;}

Which had the definition of:

public class ProductManager : IDomainService { }

And this worked perfectly within AspNetZero 6.2.

However in 10.3.0, the Manager variables are all NULL and we're not able to get a reference. So if we call


We cannot do this, because ProductManager is null.

Please advise on the changes required to support this.

Regards, Simon Dean

4 Answer(s)
  • 0
    musa.demir created
    Support Team

    DI loads Property Injected values after class created, so you can not access the data in constructor. Do you try to access the injected class in constructor? If not, please provide a screenshot or code part that contains that error.

    I tried to access property injected class in class' method and it worked.

  • 0
    hostmaster created

    Thanks Musa,

    So in the "ApplicationAppServiceBase.cs" under the Application Project:

    `public abstract class ApplicationAppServiceBase : ApplicationService { public TenantManager TenantManager { get; set; }

    public UserManager UserManager { get; set; }

    public SomeOtherManager SomeOtherManager { get; set; }

    protected ApplicationAppServiceBase() { LocalizationSourceName = ApplicationConsts.LocalizationSourceName; }

    protected virtual async Task<SomeOtherObject.SomeOtherObject> GetSomeOtherObjectAsync(UserIdentifier userIdentifier) { var object = await SomeOtherManager.GetLinkedObjectForUser(userIdentifier); return object; } }`

    TenantManager and UserManager are fine, but "SomeOtherManager" is null so we cannot call "GetSomeOtherObjectAsync" because SomeOtherManager is null.

    In the code for the manager, we have:

    `using System.Linq; using System.Threading.Tasks; using Abp.Domain.Repositories; using Abp.Domain.Services;

    namespace ACUTEC.TimeAndAttendance.OtherObject { public class SomeOtherManager : IDomainService { private readonly IRepository<OtherObject, int> _otherObjectRepository;

    public SomeOtherManager(IRepository<OtherObject, int> otherObjectRepository) { _otherObjectRepository = otherObjectRepository; }

    public async Task

    Which seems pretty standard to me.

    As I say, this worked absolutely fine in AspNetZero 6.2.0, but not in 10.3.0

    Potential difference I see is that other managers now use extend their own interface as well as the ApplicationDomainServiceBase

  • 0
    ismcagdas created
    Support Team

    Hi @hostmaster

    I don't remember any change which can cause this on our side but this might be a change on Castle Windsor side. Have you tried inheriting from ApplicationDomainServiceBase ? If that doesn't work as well, is it possible for oyu to share your project with us via email ?

  • 0
    hostmaster created

    Ha. I'm an idiot. I forgot to merge in the DbSets to DbContext. Everything's working now.