별다를 것이 없는 코드.
Visual Studio에서 Generate되는 code만을 간단히 이용하지만, Windows EventLog를 사용하는 법이 나온 부분만 체크해보면 될 것 같다.
또 하나가 있다면, ProjectInstaller 역시 살펴 볼 내용.
Windows Service를 등록하기 위해서는 InstallUtil을 이용해서 Service를 등록시켜야지 되는데 이때 등록할 ServiceName과 Service의
이름을 일치시켜주는 것이 필요하다.
Visual Studio에서 Generate되는 code만을 간단히 이용하지만, Windows EventLog를 사용하는 법이 나온 부분만 체크해보면 될 것 같다.
또 하나가 있다면, ProjectInstaller 역시 살펴 볼 내용.
Windows Service를 등록하기 위해서는 InstallUtil을 이용해서 Service를 등록시켜야지 되는데 이때 등록할 ServiceName과 Service의
이름을 일치시켜주는 것이 필요하다.
private void InitializeComponent()
{
///서비스 등록 Account와 Password, UserName을 명시해준다.
this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
//
// serviceProcessInstaller1
//
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalService;
this.serviceProcessInstaller1.Password = null;
this.serviceProcessInstaller1.Username = null;
//
// serviceInstaller1
//
///서비스에 대한 내용을 기술한다. ServiceName의 경우에는 작성한 ServiceName과 반드시 일치해야지 된다.
this.serviceInstaller1.Description = "All-In-One Code Framework Windows Service example";
this.serviceInstaller1.DisplayName = "CSWindowsService Sample Service";
this.serviceInstaller1.ServiceName = "CSWindowsService";
//
// ProjectInstaller
//
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.serviceProcessInstaller1,
this.serviceInstaller1});
}
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// Windows EventLog에 대한 초기화를 행한다.
private System.Diagnostics.EventLog eventLog1;
private void InitializeComponent()
{
this.eventLog1 = new System.Diagnostics.EventLog();
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).BeginInit();
//
// eventLog1
//
this.eventLog1.Log = "Application";
this.eventLog1.Source = "CSWindowsService";
//
// MyService
//
this.ServiceName = "CSWindowsService";
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).EndInit();
}



