Today was my first time trying to setup Autofac with WcfIntegration.
Following the instructions to the letter (almost!) I couldn’t get it to work.
I was getting the error:
The service ‘MyService’ configured for WCF is not registered with the Autofac contain
My config was fairly simple, but I still tried changing this for a good hour!
var builder = new ContainerBuilder(); builder.Register(c => new PNRResolverService(c.Resolve())); builder.RegisterType(); AutofacHostFactory.Container = builder.Build();
After much googling and turning up no results I went back to the wiki and checked the comments (Yes, I probably should have done this first).
I found my answer six comments down!
it looks like you need to use the fully-qualified name of your service in the .SVC file
Looks like I missed a small but very important part of the example in the wiki
And your .svc file would specify the appropriate service implementation type and host factory, like this:
<%@ ServiceHost Service="TestService.Service1, TestService" Factory="Autofac.Integration.Wcf.AutofacServiceHostFactory, Autofac.Integration.Wcf" %>
I changed that one tiny bit of my .svc file from `
MyProject.MyService, MyProject and it worked perfectly!