Skip to main content

Posts

Showing posts with the label ServiceHostFactory

Creating a custom Service Host Factory

Creating a custom ServiceHostFactory 1. Follow the instructions in this blog to create a custom service host. 2. Follow the instructions in this blog to Host the service in a website 3. Open the NewProdSrvHost.cs file and change the constructor as shown below: public NewProdSrvHost( params Uri [] baseAddresses) : base ( typeof ( ProductService ),baseAddresses) { } 4. Move the NewProdSrvHost to the ProductServiceLibrary Project. 5. Right click productServiceLibrary project > select Add > Class > name: ProdSrvHostFactory. 6. Make the class public and derive it from ServiceHostFactory 7. Override CreateServiceHost method Protected override Sytem.ServiceModel.ServiceHost CreateServiceHost(type { return new NewProdSrvHost(baseAddresses); } 8. Go to Svc file and add Factory attribute <%@ ServiceHost Service="ProductServiceLibrary.ProductService" Factory="ProductServiceLibrary.ProdSrvHostFactory" %> 9. Open the Svc file in ...