Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Urgent: Dependency Injection repositories not initialized #1870


User avatar
0
alikareemraja created

This is my application service. I'm i've included the follwing repositories.

public class GroupAppService : IGroupAppService
    {
        private readonly IGroupRepository _groupRepository; 
        private readonly UserManager _userManager;
        public IAbpSession AbpSession { get; set; }
        private IGroupQuizRepository _groupQuizRepository { get; set; }
        private IGroupAssignmentRepository _groupAssignmentRepository { get; set; }

Everything works fine until I include

private IPostRepository _groupSocialRepository;

Now whenever I make a call to this application service from dynamic api, the ioc container fails to initialize ALL of the repoistories. everything is null. Urgent help please i've spent a lot of time trying to fix it.


4 Answer(s)
  • User Avatar
    0
    chrisk created

    Hi There,

    Are you using EF for data access ? If so there is generic repository that you propably want to use. How do you register your repositories ?

  • User Avatar
    0
    alikareemraja created

    <cite>Chrisk: </cite> Hi There,

    Are you using EF for data access ? If so there is generic repository that you propably want to use. How do you register your repositories ?

    Thank you for the quick response! This is my repository interface

    public interface IPostRepository : IRepository<Post, Guid >
        {
        }
    

    And this is my repository.

    public class PostRepoistory : AMSRepositoryBase<Post, Guid>, IPostRepository
        {
            public PostRepoistory(IDbContextProvider<AMSDbContext> dbContextProvider)
                : base(dbContextProvider)
            {
            }
        }
    

    Hope this makes things more clear

  • User Avatar
    0
    hikalkan created
    Support Team

    Rename PostRepoistory to PostRepository than it will work.. typing mistake ;)

  • User Avatar
    0
    alikareemraja created

    <cite>hikalkan: </cite> Rename PostRepoistory to PostRepository than it will work.. typing mistake ;)

    Ah, a typo. That's embarrassing :shock: . Thank you for the help guys!