views:

41

answers:

2

hello.

i am trying to implement multiple Service Contracts via a single WCF.

i am trying to run this code:

  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
            );

but it tells me that the "blogservice" is already registered. i am loading 2 differant Interfaces which are implemented via differant classes. and i got stuck in this point.

+1  A: 

You are in fact registering IBlogService and IBlogServiceAlternate with the same Name(d) - blogService, therefore the error.

Otávio Décio
i know that, and i am doing it on purpose, the idea is to register both Interfaces to the same service.just like we could do, in case we have 2 ServiceContacts.that we would like to connect to the same service.
barroei
A: 

Just write

Component.For<IFirst,ISecond>(). /*whatever else you need*/
Krzysztof Koźmic
yeah i tried that, but the problem is that if i write Component.For<IFirst,ISecond>(). i cant have ImplementedBy<First,Second> or can i?
barroei