"not registered with the Autofac container" when using with WCF

1,787 views
Skip to first unread message

gorshing

unread,
Aug 19, 2010, 9:17:19 PM8/19/10
to Autofac
I'm trying to work Autofac into our WCF Services (these are the
services themselves, not the client/consumer), and I have yet to been
able to get past a simple error message of "The service
'AutofacWcfRepro.Service, AutofacWcfRepro' configured for WCF is not
registered with the Autofac container".

I have created a small repro at http://groups.google.com/group/autofac/web/AutofacWcfRepro.zip
which 'should' provide you with the error message as well when
browsing to http://localhost:50976/Service.svc

I have tried numerous ways to register the types and have came up
short. My google-fu has failed me and I'm looking for some help.

In the end these services will use net.tcp binding and be hosted in
IIS. I am also using Autofac-2.2.4.900-NET40.

Any help would be much appreciated.

Nicholas Blumhardt

unread,
Aug 19, 2010, 10:16:18 PM8/19/10
to aut...@googlegroups.com
Hi - the repro link is for some reason broken, email the files directly to me if you like.

Chances are you're trying to register your service classes "As" their service contract. This doesn't work with WCF, you need to register them "AsSelf" (or just not specify service interfaces at all.)

Cheers,
Nick


--
You received this message because you are subscribed to the Google Groups "Autofac" group.
To post to this group, send email to aut...@googlegroups.com.
To unsubscribe from this group, send email to autofac+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/autofac?hl=en.


Nicholas Blumhardt

unread,
Aug 19, 2010, 11:02:55 PM8/19/10
to aut...@googlegroups.com
Hi Chad,

Replace:
            builder.RegisterType<Service>().As<IService>();
With:
            builder.RegisterType<Service>();

WCF itself is strongly bound to the concrete Service implementation type, so the extra indirection of registering this against its interface doesn't pay off for much in the WCF scenarios.

Cheers,
Nick
Reply all
Reply to author
Forward
0 new messages