繁体   English   中英

温莎城堡-一类实现多个接口

[英]Castle Windsor - One class implementing multiple interfaces

我在应用程序启动时注册了两个接口,如下所示:

container.Register(Component.For(typeof(IEntityIndexController)).ImplementedBy(typeof(SnippetController)).LifeStyle.Transient);
container.Register(Component.For(typeof(ISnippetController)).ImplementedBy(typeof(SnippetController)).LifeStyle.Transient);

然后,当我尝试在此处使用第二个接口的对象(ISnippetController)上运行IoC.Resolve时,将引发以下异常:

无法创建组件'MyApp.Admin.Presenters.SnippetPresenter',因为它具有需要满足的依赖关系。 MyApp.Admin.Presenters.SnippetPresenter正在等待以下依赖项:服务:-未注册的MyApp.Admin.Controllers.ISnippetController。

如果我切换周围的注册顺序,则会抱怨找不到IEntityIndexController。 因此看来,它只选择了类的第一个注册,然后映射到该具体类的所有其他接口都将被忽略。

有什么明显的我想念的东西吗? (使用.net 3.5的ps im,温莎RC3)

您是否尝试过使用其他语法( AddComponent<> )注册?

尝试更新到最新的中继版本,看看是否有帮助。 对我来说似乎是个虫子。 如果没有发生,请创建一个包含该错误的测试,然后在此处提交

更新到最新的中继(1015),并使用转发的类型修复了该问题。 :-)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM