【发布时间】:2009-01-12 14:46:40
【问题描述】:
我在应用程序启动时注册了我的两个接口:-
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。因此,它似乎只获取一个类的第一个注册,然后忽略映射到同一个具体类的任何其他接口。
这里有什么我遗漏的明显东西吗? (ps 我使用 .net 3.5,windsor RC3)
【问题讨论】:
标签: c# castle-windsor ioc-container