CodeFluent Service Host
CodeFluent Entities is shipped with a very handy tool called the CodeFluent Service Host.
CodeFluent Service Host is a command line tool that enables you to easily host Windows services as well as Windows Communication Foundation (WCF) services. It takes care of all the plumbing: service registration, start, stop, multi threading, log and so on… It supports CodeFluent Generated services as well as other manually coded services.
Another sweet thing about it is that you can either use it in Console mode as well as in Windows Service mode. As a developer I found the Console mode very convenient since it allows me to quickly test my own services without having to install/uninstall them after each modification. Besides, you can print your traces and exceptions directly on the console! It also embeds a special out-of-the-box WCF exception handler that is capable of displaying WCF server errors without using any other external tool like the Service Trace Viewer.
The CodeFluent.Runtime.ServiceHost.exe can be found in your CodeFluent Entities installation directory. In order to work it needs only the following:
- The hosted assembly containing the service(s) and its referenced assemblies
- A standard .NET configuration file indicating the host which service to host.
- Note that if you use the Service Object Model Producer (provided out-of-the-box by CodeFluent Entities) to generate your services, it will automatically create the configuration file needed by CodeFluent Service Host. Thus to start your service in Console mode you’ll just have to run CodeFluent.Runtime.ServiceHost.exe.
- Here is an example of how to use CodeFluent Service Host in Windows Service Mode:
First we need to install the service. Here is the content of the InstallService.bat that will do it for us (This batch file can also be generated by the Service Object Model Producer):
CodeFluent.Runtime.ServiceHost.exe /i /name:MyServiceName /displayName:MyServiceDisplayName /description:"This service is a WCF services host"
Running the batch file will install your service. Then you’ll be able to manage your service as any other windows services thanks to the Windows Administration Services console:
More info in the documentation can be found here.
Note in the latest builds, CodeFluent Service Host is available in 4 editions:
- CodeFluent.ServiceHost.exe 32-bit (CLR2)
- CodeFluent.ServiceHost4.exe 32-bit (CLR4)
- CodeFluent.ServiceHost.exe 64-bit (CLR2)
- CodeFluent.ServiceHost4.exe 64-bit (CLR4)
Of course, if you use a .config file, it will have to follow the .exe name, sor for the CLR4 versions, the config file will have to be named CodeFluent.ServiceHost4.exe.config.