WCF Hosting in Windows Services

Anup1252000
Posted by in WCF category on for Beginner level | Views : 16866 red flag

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.
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

Page copy protected against web site content infringement by Copyscape

About the Author

Anup1252000
Full Name: anup hosur
Member Level:
Member Status: Member
Member Since: 8/1/2009 2:37:23 AM
Country: India
https://wordpress.com/pages/anuphosur.wordpress.com
https://wordpress.com/pages/anuphosur.wordpress.com
He is the .net developer with around 8 years of experience in technologies like c#, WCF, WPF and Asp.net. https://wordpress.com/pages/anuphosur.wordpress.com

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)