title: Console application as Windows service installation issue
body: <p>I changed my console application to use as windows service using ServiceBase. I installed it using the following command.  But I didn't find the service in services. I checked the log it says </p>
  
  <p>"No public installers with the RunInstallerAttribute.Yes attribute could be found in the C:\Test\MyService.exe assembly"</p>
  
  <p>How do I create installer for Console application? Please let me know.</p>
  
  <pre><code>"C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe" "c:\MyService.exe"
  
  
      using System.ServiceProcess;
      public static class Program
      {
          public static bool Cancelled { get; set; }
  
  
          #region Nested classes to support running as service
          public const string ServiceName = "MyService";
  
          public class Service : ServiceBase
          {
              public Service()
              {
                  ServiceName = Program.ServiceName;
              }
  
              protected override void OnStart(string[] args)
              {
                  Program.Start(args);
              }
  
              protected override void OnStop()
              {
                  Program.Stop();
              }
          }
          #endregion
  
  
          static void Main(string[] args)
          {
              if (!Environment.UserInteractive)
                  // running as service
                  using (var service = new Service())
                      ServiceBase.Run(service);
              else
              {
                  // running as console app
                  Start(args);
  
                  Console.WriteLine("Press any key to stop...");
                  Console.ReadKey(true);
  
                  Stop();
              }
  
          }
  
          private static void Start(string[] args)
          {
              // onstart code here
              try
              {
                SaveMessage();
              }
              catch (Exception e)
              {
          LogError();
              }
          }
  
          private static void Stop()
          {
              // onstop code here
              DisposeAll();
          }
  }
  </code></pre>