我有一个类的构造函数具有一个默认值的参数.使用Ninject 2.2,它将遵守[可选]属性并且正常工作,没有对声明为如下的构造函数定义绑定:
public EmployeeValidator([Optional] IValidator<PersonName> personNameValidator = null)
由于升级到Ninject 3.0,此对象的构造失败,并显示一条消息,指出提供程序返回null:
Test method ValidatorIsolated.Tests.EmployeeValidatorTest.CreateEmployeeValidatorTest threw exception:
Ninject.ActivationException: Error activating IValidator{PersonName} using conditional implicit self-binding of IValidator{PersonName}
Provider returned null.
Activation path:
2) Injection of dependency IValidator{PersonName} into parameter personNameValidator of constructor of type EmployeeValidator
1) Request for IValidator{Employee}
Suggestions:
1) Ensure that the provider handles creation requests properly.
解决方法
原文地址:https://www.jb51.cc/csharp/93443.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。