<register type="IRepository`1" mapTo="EdmRepository`1" name="edm"> <lifetime type="singleton" />
</register>
<register type="IPMP_TimeSheet_InfoServices" mapTo="PMP_TimeSheet_InfoServices">
<constructor>
<param name="_Repository">
<dependency name="edm"></dependency>
</param>
</constructor>
</register>
代码是调用:
IPMP_TimeSheet_InfoServices _IPMP_TimeSheet_InfoServices = myUnityContainer.Resolve<PMP_TimeSheet_InfoServices>();
总是报错:
Resolution of the dependency failed, type = "PSA.Services.PMP_TimeSheet_InfoServices", name = "(none)". Exception occurred while: while resolving. Exception is: InvalidOperationException - The current type, iPSA.Extensions.Repository.IRepository`1[iPSA.SealManagement.DataModel.PMP_TimeSheet_Info], is an interface and cannot be constructed. Are you missing a type mapping? ----------------------------------------------- At the time of the exception, the container was:
Resolving PSA.Services.PMP_TimeSheet_InfoServices,(none) Resolving parameter "_Repository" of constructor PSA.Services.PMP_TimeSheet_InfoServices(iPSA.Extensions.Repository.IRepository`1[[iPSA.SealManagement.DataModel.PMP_TimeSheet_Info, DataModel, Version=1.1.1206.8, Culture=neutral, PublicKeyToken=null]] _Repository) Resolving iPSA.Extensions.Repository.IRepository`1[iPSA.SealManagement.DataModel.PMP_TimeSheet_Info],(none)
那位大哥能帮忙看下,困扰很长时间
myUnityContainer.Resolve<PMP_TimeSheet_InfoServices>();
應該改成接口哦
myUnityContainer.Resolve<IPMP_TimeSheet_InfoServices>();
我改成了接口还是出错 Resolving PSA.Services.IPMP_TimeSheet_InfoServices,(none)
这是个什么问题
@hello zly: PMP_TimeSheet_InfoServices 类 。有几个 构造函数。需要的加上一个 dependency属性 看看。
@無限遐想: 已经解决!还是自己不够细心啊!谢谢你的帮助!