[英]ServiceStack/Funq cannot resolve System.Boolean exception
I've setup a ServiceStack api using the built-in Funq IoC container to resolve my repositories. 我已经使用内置的Funq IoC容器设置了ServiceStack api来解析我的存储库。 However, when I call an api method, I get the following exception:
但是,当我调用api方法时,出现以下异常:
Required dependency of type System.Boolean could not be resolved.
无法解析类型为System.Boolean的必需依赖项。
Last time I checked System.Boolean didn't require any resolving. 上一次我检查System.Boolean不需要任何解决。 I've registered my repositories in the AppHost Configure as follows:
我已经在AppHost Configure中注册了我的存储库,如下所示:
container.RegisterAutoWiredAs<OrganisationRepository, IOrganisationRepository>().ReusedWithin(ReuseScope.Request);
This is my first time using ServiceStack or Funq. 这是我第一次使用ServiceStack或Funq。 Am I doing anything wrong?
我做错什么了吗? Is there a way around this?
有没有解决的办法?
If you use container.RegisterAutoWiredAs<T,IT>()
then Funq will auto-wire the Repository by convention, ie use the largest constructor and resolve and inject each public property dependency of your Repository. 如果使用
container.RegisterAutoWiredAs<T,IT>()
则Funq将按照约定自动连接存储库,即使用最大的构造函数并解析并注入存储库的每个公共属性依赖项。
To use an alternate specific constructor, or only autowire specific properties you would have to specify the registration manually with: 要使用替代的特定构造函数,或仅使用自动装配特定的属性,您必须使用以下方法手动指定注册:
container.Register<IOrganisationRepository>(c =>
new OrganisationRepository(c.Resolve<IFoo>()) { Bar = c.Resolve<IBar>() } );
Note: whenever you have IOC issues like this, you should also include the skeleton of your class. 注意:每当遇到类似IOC的问题时,还应包括课程的框架。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.