June 14th, 2007 – Version 1.2 – Pascal Belaud – Microsoft France
DynamicWCFServicesHoster is a windows service that allows you to host all your Windows Communication Foundation services automatically. All you have to do is to provide a regular XML configuration file with the classical <system.serviceModel /> entries you are used to use and DynamicWCFServicesHoster will do the hosting for you.
information is available at:
build, including this documentation, is available at:
Copy the windows server DynamicWCFServicesHoster.exe anywhere on your computer. We are going to assume that this file is located in the following directory:
We are going now to install once for good this application as a Windows service. Open a command console, as an administrator, and type the following:
"%windir%\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe" "C:\Program Files\DynamicWCFServicesHoster\DynamicWCFServicesHoster.exe"
You are now ready to use this service to host all your WCF services:
In order to host your WCF services (using any techniques), you know that you need to create an XML configuration and specify all the WCF information needed by the WCF runtime. You can create this configuration file by hand or by using the WCF Configuration Editor located in the Windows SDK tools directory:
This is no different when using DynamicWCFServicesHoster.
As an example, let’s say that we have two different WCF contracts, WCFInterfaces1.IService1 and WCFInterfaces2.IService2, in two different assemblies. Those contracts are implemented in two different classes, WCFServices1. Services1 and WCFServices2. Services2, located in two others separate assemblies:
Using the SvcConfigEditor tool, we are going to configure the DynamicWCFServicesHoster windows service to host automatically our two services.
We are going now to declare the two services. Service1 will be available via netTcpBinding and Service2 will be available via basicHttpBinding:
If you try to start the DynamicWCFServicesHoster windows service, you will notice that it won’t start and taking a look at the Application EventLog will give you a hint of what is going on:
The error message is pretty clear. Everything is just fine except the fact that the DynamicWCFServicesHoster windows service has no idea where to load the assemblies from. You will need to supply this information in the <appSettings> section of the XML configuration file. You can do this using any XML file manipulation tool. In my case, I’m using XML Notepad 2007:
which end up with the following XML:
Now you should be able to successfully start the windows service:
This is will be confirmed by the entry in the Application EventLog that should look like this:
Now you are ready to call your WCF services from any client application!