별다를 것이 없는 코드.
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의
이름을 일치시켜주는 것이 필요하다.
01.
private
void
InitializeComponent()
02.
{
03.
///서비스 등록 Account와 Password, UserName을 명시해준다.
04.
this
.serviceProcessInstaller1 =
new
System.ServiceProcess.ServiceProcessInstaller();
05.
this
.serviceInstaller1 =
new
System.ServiceProcess.ServiceInstaller();
06.
//
07.
// serviceProcessInstaller1
08.
//
09.
this
.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalService;
10.
this
.serviceProcessInstaller1.Password =
null
;
11.
this
.serviceProcessInstaller1.Username =
null
;
12.
//
13.
// serviceInstaller1
14.
//
15.
///서비스에 대한 내용을 기술한다. ServiceName의 경우에는 작성한 ServiceName과 반드시 일치해야지 된다.
16.
this
.serviceInstaller1.Description =
"All-In-One Code Framework Windows Service example"
;
17.
this
.serviceInstaller1.DisplayName =
"CSWindowsService Sample Service"
;
18.
this
.serviceInstaller1.ServiceName =
"CSWindowsService"
;
19.
//
20.
// ProjectInstaller
21.
//
22.
this
.Installers.AddRange(
new
System.Configuration.Install.Installer[] {
23.
this
.serviceProcessInstaller1,
24.
this
.serviceInstaller1});
25.
}
01.
/// Required method for Designer support - do not modify
02.
/// the contents of this method with the code editor.
03.
/// Windows EventLog에 대한 초기화를 행한다.
04.
private
System.Diagnostics.EventLog eventLog1;
05.
private
void
InitializeComponent()
06.
{
07.
this
.eventLog1 =
new
System.Diagnostics.EventLog();
08.
((System.ComponentModel.ISupportInitialize)(
this
.eventLog1)).BeginInit();
09.
//
10.
// eventLog1
11.
//
12.
this
.eventLog1.Log =
"Application"
;
13.
this
.eventLog1.Source =
"CSWindowsService"
;
14.
//
15.
// MyService
16.
//
17.
this
.ServiceName =
"CSWindowsService"
;
18.
((System.ComponentModel.ISupportInitialize)(
this
.eventLog1)).EndInit();
19.
}