Debug Windows Service

I recommend following pattern for debug: var ServiceToRun = new SomeService(); if (Environment.UserInteractive) { // This used to run the service as a console (development phase only) ServiceToRun.Start(); Console.WriteLine(“Press Enter to terminate …”); Console.ReadLine(); ServiceToRun.DoStop(); } else { ServiceBase.Run(ServiceToRun); } Edit: make sure that your target is Console Application, not Windows Application, otherwise it will … Read more

Self install Windows Service in .NET

This is my complete solution, and it works. It is basically the same answer as in this question. using System; using System.Configuration.Install; using System.Reflection; using System.ServiceProcess; using System.IO; namespace ConsoleApplication1 { class Program : ServiceBase { static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException; if (System.Environment.UserInteractive) { string parameter = string.Concat(args); switch (parameter) { case … Read more

Start stop Service from Form App c#

Add a reference to System.ServiceProcess.dll. Then you can use the ServiceController class. // Check whether the Alerter service is started. ServiceController sc = new ServiceController(); sc.ServiceName = “Alerter”; Console.WriteLine(“The Alerter service status is currently set to {0}”, sc.Status.ToString()); if (sc.Status == ServiceControllerStatus.Stopped) { // Start the service if the current status is stopped. Console.WriteLine(“Starting the … Read more

Run a Windows Service as a console app

Before a Windows Service can run, it has to be “installed” first using installutil. EG: C:\installutil -i c:\path\to\project\debug\service.exe Then you can open up the list of Services to start it. EG: Right click ‘My Computer’ Click on ‘Manage’ Open up ‘Services and Applications’ Click on ‘Services’ Find your service in the list and right-click on … Read more

How can a Windows service application be written in Haskell?

I admit, this problem has been vexing me for some days now. From walking the return values and the contents of GetLastError, I’ve determined that this code should be working correctly according to the system. Because it clearly isn’t (it seems to enter an undefined state that inhibits the service handler from running successfully), I’ve … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)