Thursday, 15 January 2015

c# - How to transform console application to service application -


I am trying to create a Windows service using C #.

My problem is that I only have Visual Studio Express 2010 so I can not generate a "service application" My console application is working and I use it as a service using Ino Setup Has installed.

But of course, if the service is not starting, then my question is, what coding differences between the console application and a Windows service - what do I do to make my application work as a service needed.

Thanks

I would recommend to convert a lot of console applications into a Windows service . The expected code changes are actually minimal; Public level service {Public zero start ()} {// when your code was started} public zero-stop () {// when your code was stopped}} Public class program {public static zero main () (HostFactory.Run (X = & gt; {x.Service (s => {s.ConstructUsing (name => New Service ()); s.WhenStarted (tc = & gt; tc. Start;); S.WhenStopped (tc = & gt; tc.Stop ());}); x.RunAsLocalSystem (); x.SetDescription ("My service description"); x.SetDisplayName ("ServiceName"); x .SetServiceName ("service name");}); }}

to install it from the command line

  install service.exe    < / Html>

No comments:

Post a Comment