WCF: Hosting WCF in Windows Service

1. Create a windows service projectwindows

 

2. Add Reference to the assembly which contains the contract and its implementation.ide

3. Remove the Service1.cs, add a new Windows Service class and name it to CalculatorWindowsServiceui

4. Override OnStart and OnStop method in WindowsServiceHost classblog

  a. instantiate ServiceHost and open it in Onstartit

  b. Close the ServiceHost in Onstopio

 

5. Create a Installer class to allow the exe to be installed as windows serviceclass

6. Instantiate a CalculatorWindowsService in the Program Main method.service

 

7. Edit App.config and add configuration info for the serviceim

 

8. Build Project and execute installutil.exe /i WindowsServiceHost.exe to install the service.d3

9. Open services.msc and start the service.

相關文章
相關標籤/搜索