Go to DotNetFunda.com
 Online : 1756 |  Welcome, Guest!   Login
 
Home > Articles > WCF > WCF Hosting in Windows Services

  • Download the OOPS, ASP.NET and ADO.NET online training sessions videos and related document for FREE, click here.

Submit Article | Articles Home | Search Articles |

WCF Hosting in Windows Services

 Posted on: 1/28/2010 7:53:50 AM by Anup1252000 | Views: 523 | Category: WCF | Level: Beginner | Print Article
In this article, we are going to see how to host Windows service in WCF and automatically start and stop the Service by using Button click events.

.NET Training Videos!
Buy online comprehensive training video pack just for $35.00 only, see what's inside it.

Introduction
            In this article, we are going to see how to host Windows service in WCF and automatically start and stop the Service by using Button click events.

Let us go through this application step by step



Step1:
  I suggest you to go through this article
 http://msdn.microsoft.com/en-us/library/ms733069.aspx
Implement the same. Actually i need to explain a lot of thing here,so i suggested you to go through this article.


Step2:
  Create a new Web For application->name it->Add the service reference to it.

  In the Form design, add 2 button's one as start,another as stop and put a label to it.


Step3:
   Now give a reference to System.ServiceProcess.
 
   Now add your service reference to generate the proxy and we are going to use ServiceController method to automatically start and stop the service.





Step4:

   Now ,in the Form load event write these lines

  


Scratched content contains computer name.Because its confidential i can't disclose infront of you people. Service name is the same whatever i suggested you people to read. We are checking the status, if it suggests that service is running then there is no point in stopping the service.


Step5:
   Now let see what we are going to do in start and stop functionality.




I implemented the same functionality whatever i did in form load event.


I hope you people like this article.

Reference:
http://msdn.microsoft.com/en-us/library/ms733069.aspx


If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Interesting?   Share and Bookmark this kick it on DotNetKicks.com


About anup hosur

Experience:2 year(s)
Home page:
Member since:Saturday, August 01, 2009
Level:Starter
Status: [Member]
Biography:
 Latest post(s) from Anup1252000

   ◘ 4 steps to enable instrumentation in WCF posted on 3/14/2010 4:02:05 AM
   ◘ Ajax Enabled WCF Service posted on 2/15/2010 1:10:10 AM
   ◘ Membership provider with WCF posted on 2/11/2010 7:00:47 AM
   ◘ Creating Multiple Channels in Channel factory in WCF posted on 2/11/2010 4:06:00 AM
   ◘ WCF Hosting in Windows Services posted on 1/28/2010 7:53:50 AM


Submit Article

About Us | The Team | Advertise | Contact Us | Feedback | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you found copied contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
All rights reserved to DotNetFunda.Com. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks.
(Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher)