0

I am trying to register my WCF services with Castle Windsor on my WinForms client using the WCFFacility. I can easily do this one at a time using

container.Register(Component.For<IMyService>()
    .AsWcfClient(new DefaultClientModel
    {
        Endpoint = WcfEndpoint.BoundTo(new BasicHttpBinding { MaxReceivedMessageSize = 3000000 })
            .At("http://localhost:51324/MyService.svc")
    }));

However I have hundreds so tried to follow this answer

I used this code:

container.Register(
    Types
        .FromAssemblyContaining<IMyService>()
        .Pick()
        .If(s => s.Name.EndsWith("Service"))
        .Configure(
            configurer => configurer.Named(configurer.Implementation.Name)
                .AsWcfClient(new DefaultClientModel
                {
                    Endpoint = WcfEndpoint.BoundTo(new BasicHttpBinding { MaxReceivedMessageSize = 3000000 })
                        .At(string.Format("http://localhost:{0}/{1}.svc", Port, configurer.Name.Substring(1)))
                })));

Unfortunately this gives me the following error when trying to resolve my service: "Type MyNamespace.IMyService is abstract. As such, it is not possible to instantiate it as implementation of service 'IMyService'. Did you forget to proxy it?"

Community
  • 1
  • 1
Huw Pendry
  • 95
  • 8

1 Answers1

1

Fixed it! I think that the problem was simply that some other non-service classes were throwing exceptions causing the registration to fail. I hadn't included the call to add the WcfFacility!

Container.Kernel.AddFacility<WcfFacility>();

Presumably the registration just failed resulting in Windsor registering the interface as the implementing class.

Huw Pendry
  • 95
  • 8