Can't create component as it has dependencies to be satisfied

自古美人都是妖i 提交于 2019-12-18 15:53:41

问题


I am learning DDD, n-Tier, Repositoriess and the likes. Someone pointed me to ASP.NET Boilerplate and I decided to start a test project using that. I have never dealt with dependency injection so this is all new to me, but the DI dependency it uses ius Castle Windsor. Now, I created a Model and from this Model I created an interface. I also added a Service. Whenever I fire up the app it gives me this error:

Can't create component 'TestApp.Services.MemberInfo.MemberAppService'
as it has dependencies to be satisfied.

'TestApp.Services.MemberInfo.MemberAppService' is waiting for the following dependencies:
- Service 'TestApp.Repositories.IMemberInfoRepository' which was not registered.

I know you've got to register services and the likes, but reading ABPs documentation it says here, http://www.aspnetboilerplate.com/Pages/Documents/Dependency-Injection#DocAbpInfrastructure, that they are registered automatically if you add App to the name of the class. Basically, this is my code:

IMemberInfoRepository

    public interface IMemberInfoRepository : IRepository<MemberInfo, Guid>
{

}

MemberAppService

 public class MemberAppService : IMemberAppService
{
    private readonly Repositories.IMemberInfoRepository _memberInfoRepository;

    public MemberAppService(Repositories.IMemberInfoRepository memberInfoRepository)
    {
        _memberInfoRepository = memberInfoRepository;
    }

    public void Create(MemberInfoDto input)
    {
      _memberInfoRepository.Insert(AutoMapper.Mapper.Map<m.MemberInfo>(input));
    }

IMemberAppService

public interface IMemberAppService :IApplicationService
{
    void Create(MemberInfoDto input);
}

So, here I am. Stuck. I read some Castle Windsor official documentation but as this is my first rodeo with this I am stuck at on what to do. Anything else would be greatly appreciated.


回答1:


I had the same problem but I could solve it!

This is a screenshot of the error given by IIS.

The reason of the error is that ABP cannot find the defined entity class Member.

The solution was to add the code public virtual IDbSet<Members> Members { set; get; }in the DbContext of the EntityFramework Project.




回答2:


after my workmate updated one ABP version, I met the same error. I checked my old code. found that, he missed to attach one cs file to the project. then I recoved it, now it works. please check whether you have similar file in the same path, wish it can help you.

[EF project]\EntityFramework\Repositories\xxxxRepository.cs

if you did not have, please create a similar one as xxxxRepositoryBase.cs



来源:https://stackoverflow.com/questions/32365420/cant-create-component-as-it-has-dependencies-to-be-satisfied

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!