WCF: Hosting WCF in Windows Service

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.

时间: 2024-08-04 02:38:19

WCF: Hosting WCF in Windows Service的相关文章

WCF - Hosting WCF Service

After creating a WCF service, the next step is to host it so that the client applications can consume it. This is known as WCF service hosting. A WCF service can be hosted by using any of the four ways given below: 在创建wcf服务后,下一个步骤就是托管该服务,确保客户端应用可以使用它

WCF: Hosting WCF In IIS

1. Create an IIS Application as below 2. In the physical path, there're 2 files and 1 App_Code folder a. App_code contains the WCF Service contract and class implementing the contract b. service.svc contains code hosts the service c. Web.config confi

WCF - Windows Service Hosting

WCF - Windows Service Hosting The operation of Windows service hosting is a simple one. Given below are the steps with requisite coding and screenshots that explain the process in an easy way. 在windows服务上托管wcf是一个简单的操作. Step-1: Now let’s create a WCF

WCF注册Windows Service

WCF注册Windows Service 2014-06-14 返回 在前面创建一个简单的WCF程序,我们把WCF的服务寄宿到了Host这个控制台项目中了.下面将介绍如何把WCF的服务寄宿到Windows服务中: 1. 删除原来Host控制台项目,然后在solution上右键,新建一个WindowService项目.如下图: 2.对MyFirstWindowsService项目添加对Contracts项目.Service项目和System.ServiceModel的引用. 3.将MyFristW

WCF Windows Service Using TopShelf and ServiceModelEx z

http://lourenco.co.za/blog/2013/08/wcf-windows-service-using-topshelf-and-servicemodelex/ There are two excellent .NET libraries that help us to build enterprise solutions using the Windows Communication Foundation (WCF) – TopShelf and ServiceModelEx

WCF - Consuming WCF Service

WCF services allow other applications to access or consume them. A WCF service can be consumed by many ways depending on the hosting type. Here, we are explaining the step-by-step method to consume a WCF service for each of the following popular host

转载——Java与WCF交互(二):WCF客户端调用Java Web Service

在上篇< Java与WCF交互(一):Java客户端调用WCF服务>中,我介绍了自己如何使用axis2生成java客户端的悲惨经历.有同学问起使用什么协议,经初步验证,发现只有wsHttpBinding可行,而NetTcpBinding不可行,具体原因待查.昨晚回去重新测试WCF客户端调用Java Web Service,并将过程公布如下: 其实本不需要做web service,只是原来公开的经典的Web service像(http://soapinterop.java.sun.com/rou

Learning WCF Chapter1 Creating a New Service from Scratch

You’re about to be introduced to the WCF service. This lab isn’t your typical “Hello World”—it’s “Hello Indigo”! In this lab,you will learn how to build a new WCF service and in the process learn the minimum requirements of service development and co

Hosting Web API in Windows service

Running your api as Windows services can have multiple advantages, especially when working on bigger projects. This allows for multiple (services to run in isolation and gives fine grained control over your system components. ASP.NET Web API ships wi