Adding IoC Support to My WCF Service Hosted in a Windows Service (Autofac)

I would like to configure my WCF services to use the IoC container. There is an article in the Autofac wiki about WCF integration, but it only shows integration with a service hosted in IIS.

But my services are hosted on a windows service.

Here I received a recommendation to enable the opening event http://groups.google.com/group/autofac/browse_thread/thread/23eb7ff07d8bfa03

I went for advice, and this is what I got so far:

    private void RunService<T>()
    {
        var builder = new ContainerBuilder();

        builder.Register(c => new DataAccessAdapter("1")).As<IDataAccessAdapter>();

        ServiceHost serviceHost = new ServiceHost(typeof(T));

        serviceHost.Opening += (sender, args) => serviceHost.Description.Behaviors.Add(
            new AutofacDependencyInjectionServiceBehavior(builder.Build(), typeof(T), ??? ));                      


        serviceHost.Open();
     }

AutofacDependencyInjectionServiceBehavior has a ctor that takes 3 parameters. The third type is type IComponentRegistration, and I have no idea where to get it. Any ideas?

Thanks in advance.

+5

All Articles