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" %>
Note the Service="TestService.Service1, TestService"
I changed that one tiny bit of my .svc file from `MyProject.MyService` to MyProject.MyService, MyProject and it worked perfectly!
Thanks for the post – it helped me figure this out in 5 minutes; otherwise I’m sure I’d have spent at least an hour on it also.
Wow, after several hours….how simple can it be ! Thanks !
I thank you sooooo much.
Took me hours to investigate and being the problem so close I can’t even see it without your help.
I spent most the day on this…MyProject.MyService, MyProject …..thank very much!!!
Thank you so much! I wish I could gift you reddit gold.