混合“传统”控制器与 Castle-Windsor 控制器。这可能吗?
我正在将一系列控制器集成到现有项目中,该项目已包含使用 Castle Windsor 进行 DI/IoC 的控制器。我已将安装程序修改为仅在某个命名空间(特别是根命名空间)中注册控制器。这一修改似乎正在发挥作用。当我尝试访问我的控制器时,该控制器不使用温莎城堡并且位于不同的命名空间(特别是自定义区域)中,我收到错误消息:“找不到支持服务 [控制器名称] 的组件”。
是否可以在单个项目中将“传统”控制器与使用温莎城堡的控制器混合使用?
这有道理吗?
I'm integrating a series of controllers into an existing project which already contain controllers which use Castle Windsor for DI/IoC. I've modified the Installer to only register Controllers in a certain namespace (specifically the root). This modification appears to be working. When I try to access my controllers, which do not use Castle Windsor and are located in a different namespace (specifically, a custom Area), I get the error message: "No component for supporting the service [Controller Name] was found".
Is it possible to mix "traditional" controllers with controllers which use Castle Windsor in a single project?
Does this make sense?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您收到该错误,则说明您正在尝试通过容器(直接或间接)解析控制器。
如果您有一个单独的逻辑路径,需要一个未从容器注册的控制器,那么没有什么可以阻止您调用
new MyController()
。顺便说一句,从使用容器的控制器的角度思考有点倒退。容器管理您的实例——您的实例不知道它们是否是容器管理的。
If you are getting that error, you are trying to resolve the controller (directly or indirectly) through the container.
If you have a separate logic path that needs a controller that isn't register from the container, nothing is stopping you from calling
new MyController()
.As an aside, thinking in terms of the controller using the container is somewhat backwards. The container manages your instances--your instances have no idea whether they are container-managed or not.