WCF: Hosting WCF in Windows Service, wcfhosting

Source: Internet
Author: User

WCF: Hosting WCF in Windows Service, wcfhosting

1. Create a windows service project

 

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

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

4. Override OnStart and OnStop method in WindowsServiceHost class

A. instantiate ServiceHost and open it in Onstart

B. Close the ServiceHost in Onstop

 

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

6. Instantiate a CalculatorWindowsService in the Program Main method.

 

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

 

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

9. Open services. msc and start the service.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.