Cleaner WCF Facility registration

Skip to first unread message

Mark Seemann

Feb 12, 2010, 11:04:28 AM2/12/10
to Castle Project Users
As far as I understand the Windsor WCF Facility, it requires me to
invoke the static WindsorServiceHostFactory.RegisterContainer method
from within Application_Start in a Global.asax(.cs?) file. I'm
referring to this documentation:

I find this... not as nice as it could be.

It smells of ASP.NET, of which I'm not a particularly big fan, but it
also makes me uneasy because I've never seen the combination of
Global.asax and WCF before. Does it require me to turn on ASP.NET
Compatibility mode before it will work?

This may simply be a severe case of FUD on my part, but I would
appreciate a cleaner API.

May I suggest something like this:

public abstract class WindsorServiceHostFactory : ServiceHostFactory
// ... other members

protected abstract IWindsorContainer CreateContainer();

This is basically just a ServiceHostFactory with a Template Method.
All I would need to do to wire up my own service would be to derive
from this class and implement the CreateContainer method. Registering
this derived ServiceHostFactory in my .svc file would enable Windsor
to wire up my service.

This approach requires me to edit/create the same number of files (2)
as the current approach, but has the added benefit that it will also
work outside of IIS, since I could simply use the derived
ServiceHostFactory directly to spin up a new service.

Craig Neuwirt

Feb 12, 2010, 11:10:19 AM2/12/10
Sorry, docs are out of date (in process of being updated).  You don't need to do anything besides register facility

You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply all
Reply to author
0 new messages