无法创建组件,因为它具有要满足的依赖关系 [英] Can't create component as it has dependencies to be satisfied
问题描述
我正在学习DDD,n-Tier,存储库等.有人将我指向ASP.NET Boilerplate,因此我决定使用该项目启动一个测试项目.我从未处理过依赖注入,因此这对我来说是全新的,但是它使用ius Castle Windsor的DI依赖.现在,我创建了一个模型,并从该模型中创建了一个接口.我还添加了服务.每当我启动应用程序时,都会出现此错误:
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.
我知道您必须注册服务之类的东西,但是在这里阅读ABP文档说, http://www.aspnetboilerplate.com/Pages/Documents/Dependency-Injection#DocAbpInfrastructure ,如果您将App添加到类名中,则会自动注册它们.基本上,这是我的代码:
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
IMemberInfoRepository
public interface IMemberInfoRepository : IRepository<MemberInfo, Guid>
{
}
MemberAppService
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
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.
推荐答案
我遇到了同样的问题,但我可以解决!
I had the same problem but I could solve it!
这是IIS给出的错误的屏幕截图.
This is a screenshot of the error given by IIS.
错误的原因是ABP无法找到已定义的实体类Member
.
The reason of the error is that ABP cannot find the defined entity class Member
.
解决方案是在EntityFramework
项目的DbContext中添加代码public virtual IDbSet<Members> Members { set; get; }
.
The solution was to add the code public virtual IDbSet<Members> Members { set; get; }
in the DbContext of the EntityFramework
Project.
这篇关于无法创建组件,因为它具有要满足的依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!