I had a problem today. a WCF service was failng to return “OK” while the host process was running properly with no indications of failing. So i started the to look for solutions. Here are some usefull links that might save your day.
How To: Debug a Self-Hosted WCF Service – http://msdn.microsoft.com/en-us/library/bb157685.aspx
Configuring IIS hosted WCF services runtime
In the SVC file of your service there is Factory attribute. To reach it right click on your service svc file and click “View Markup”. Then modify it.
In my case is used descendant of WebServiceHostFactory. In this class you would want to create your own WebServiceHost descendant and configure it the way you want.
When hosting your service, every time you hit the service the MyWebServiceHost class you implemented will be created for serving your request.
Your service svc file should look like this :
<%@ ServiceHost Language="C#" Debug="true" Service="name.space.myService"CodeBehind="name.space.myService.svc.sc" Factory = "name.space.WebServiceHostFactoryEx, assembly.name" %>The WebServiceHostFactory will be created for every service hit and will recreate your host the you want it.
You will also need to inherith WebServiceHost and create it the way you need it with certain endpoins, behaviors, addresses, etc settings – whatever you like.
There is very nice post from Michele Bustamante here.
I am using this in IIS hosted enviroment for couple of services that are initialized same way.