This project provides base classes that extend System.ServiceModel to allow for create service instances and resolving dependencies using the container of your choice. The include example projects show the pattern to use the ContainerHost.ServiceModel classes. In general the pattern is:

1. Create an implementer of ContainerHost.ServiceModel.IContainer for your container and implement Resolve(type t)
2. Create a Service host Factory that derives from System.ServiceModel.Activation.ServiceHostFactory
-In the CreateServiceHost method create an instance of the ContainerHost.ServiceModel.ContainerServiceHost
-Create an instance of your IContainer Implementer and attach the container to the ContainerServiceHost container property.
3. Configure your WCF host environment to use the custom service host factory

See the example for ideas on how to do this. In general you would follow these three steps for each service you want to use a container for. Depending on your requirements you may be able to combine some of that work.

Key Projects:
Contains the base classes which extend System.ServiceModel and provide a Service Host, Behavior, and instance provider which work together to resolve Service Types from a container. This project also contains the basic IContainer Interface which should be implemented to support the container you want to use with the custom service host.

Sample implementation of using StructureMap with the custom service host. The implementation is specifically for the sample Person Service.

Sample implementation using Unity with configuration. Same idea as the StructureMap example.

Last edited Nov 23, 2009 at 8:30 PM by cdeweese, version 1


shlfung Jan 31, 2012 at 3:57 PM 
Thank you Chris! This has been a very helpful reference for me.