2017-10-18 1 views
0

관리자 모드에서 다음 명령을 사용하여 installUtil.exe를 사용하여 자체 Windows 서비스를 설치하려고합니다.서비스를 설치하는 동안 InstallUtil이 작동하지 않습니다.

InstallUtil C:\Users\Admin\Desktop\Subway_sync\SubwaySync\SubwaySync\bin\Debug\SyncSQL.exe

나는 다음과 같이 cmd를 출력을 얻을 및 설치가 바로 거기에 붙어있다. 설치된 서비스로 net start를 발행 할 때

----------------------------------- Installing Service. 
Microsoft (R) .NET Framework Installation utility Version 4.7.2046.0 
Copyright (C) Microsoft Corporation. All rights reserved. 


Running a transacted installation. 

Beginning the Install phase of the installation. 
See the contents of the log file for the C:\Users\Admin\Desktop\Subway_sync\SubwaySync\SubwaySync\bin\Debug\SyncSQL.exe assembly's progress. 
The file is located at C:\Users\Admin\Desktop\Subway_sync\SubwaySync\SubwaySync\bin\Debug\SyncSQL.InstallLog. 
Installing assembly 'C:\Users\Admin\Desktop\Subway_sync\SubwaySync\SubwaySync\bin\Debug\SyncSQL.exe'. 
Affected parameters are: 
    logtoconsole = 
    logfile = C:\Users\Admin\Desktop\Subway_sync\SubwaySync\SubwaySync\bin\Debug\SyncSQL.InstallLog 
    assemblypath = C:\Users\Admin\Desktop\Subway_sync\SubwaySync\SubwaySync\bin\Debug\SyncSQL.exe 

서비스는 서비스 뷰어 나 CLI에도 보이고있다.

다음은 설치 관리자 및 서비스 클래스 코드입니다.

using System.ComponentModel; 
using System.ServiceProcess; 

namespace SubwaySync 
{ 
    [RunInstaller(true)] 
    public partial class Installer : System.Configuration.Install.Installer 
    { 
     private ServiceInstaller serviceInstaller; 
     private ServiceProcessInstaller processInstaller; 

     public Installer() 
     { 
      // Instantiate installers for process and services. 
      processInstaller = new ServiceProcessInstaller(); 
      serviceInstaller = new ServiceInstaller(); 

      // The services run under the system account. 
      processInstaller.Account = ServiceAccount.LocalSystem; 

      // The services are started manually. 
      serviceInstaller.StartType = ServiceStartMode.Automatic; 

      // ServiceName must equal those on ServiceBase derived classes. 
      serviceInstaller.ServiceName = "SyncSQL"; 

      // Add installers to collection. 
      Installers.Add(serviceInstaller); 
      Installers.Add(processInstaller); 
      InitializeComponent(); 
     } 
    } 

    public partial class SubwaySync : ServiceBase 
    { 
     EventLog e = new EventLog(); 
     private System.Timers.Timer _timer; 

     public SubwaySync() 
     { 
      InitializeComponent(); 

      if (!System.Diagnostics.EventLog.SourceExists("DoDyLogSourse")) 
       System.Diagnostics.EventLog.CreateEventSource("DoDyLogSourse", "DoDyLog"); 

      e.Source = "DoDyLogSourse"; 
      // the event log source by which 
      //the application is registered on the computer 

      e.Log = "DoDyLog"; 
      Thread.Sleep(60001); 
     } 
     protected override void OnStart(string[] args) 
     { 
      _timer = new System.Timers.Timer(TimeSpan.FromMinutes(1).TotalMilliseconds); // 10 minutes expressed as milliseconds 
      _timer.Elapsed += new ElapsedEventHandler(OnTimerElapsed); 
      _timer.AutoReset = true; 
      _timer.Start(); 
     } 

     protected override void OnStop() 
     { 
      _timer.Stop(); 
      _timer.Dispose(); 
     } 

     private void OnTimerElapsed(object sender, ElapsedEventArgs e) 
     { 
      // Do your work here... 
     } 
    } 
} 
+1

설치하는 데 사용하는 명령을 게시 할 수 있습니까? –

+1

관리자 모드에서 명령 프롬프트를 실행 했습니까? –

+0

그래, 질문이 업데이트되었습니다. –

답변

0
Thread.Sleep(60001); 

서비스 클래스 (SubwaySync)에서이 줄은 지연이 발생합니다.

관련 문제