wcf - CaSTLe Windsor 组件在单个服务上注册多个接口(interface)

标签 wcf castle-windsor ioc-container

我正在尝试通过单个 WCF 实现多个服务契约(Contract)。

我正在尝试运行此代码:

  return new WindsorContainer()
            .AddFacility<WcfFacility>()
            .Register(
                Component.For<IServiceBehavior>().Instance(metadata),
                Component.For<IServiceBehavior>().Instance(debug),
                Component
                    .For<IBlogService>()
                    .ImplementedBy<DefaultBlogService>()
                    .Named("blogService")
                    .LifeStyle.Transient
                    .ActAs(new DefaultServiceModel().Hosted()
                        .AddEndpoints(
                            WcfEndpoint.BoundTo(new BasicHttpBinding()))),
                Component
                    .For<IBlogServiceAlternate>()
                    .ImplementedBy<AlternateBlogService>()
                    .Named("blogService")
                    .LifeStyle.Transient
                    .ActAs(new DefaultServiceModel().Hosted()
                        .AddEndpoints(
                            WcfEndpoint.BoundTo(new BasicHttpBinding()))),


                Component
                    .For<ILogger>()
                    .ImplementedBy<DefaultLogger>()
                    .LifeStyle.Transient
            );

但它告诉我“blogservice”已经注册。 我正在加载两个不同的接口(interface),它们是通过不同的类实现的。 我陷入了这一点。

最佳答案

直接写

Component.For<IFirst,ISecond>(). /*whatever else you need*/

关于wcf - CaSTLe Windsor 组件在单个服务上注册多个接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3592188/

相关文章:

c# - 我如何处理 StructureMap 的 ObjectFactory 中的每个实例对象?

.net - Enterprise Services 的事务和池功能是否有现代替代品?

wcf - 测试 SOAP WCF Web 服务的 URL 是什么?

c# - 温莎城堡 :- Inject Dictionary of Interfaces via configuration

c# - 结构图 - 如何在特定层中注册特定类型

java - 创建 bean 时出错,无法将新的 LinkedBlockingQueue 作为构造函数注入(inject)到 ThreadPoolExecutor

c# - WCF 到 Entity Framework 将我的日期时间转换为本地时间 - 如何停止?

.net - 用户代码中未处理 WebFaultException

c# - CaSTLe Windsor - 组件的登台与生产连接字符串参数

nhibernate - 使用 CaSTLe.Facilities.AutoTx 运行 NHibernate 时出现 MissingTransactionException