Visual Studio에서 만든 Windows 서비스 설치
Visual Studio 2010에서 새 Windows 서비스를 만들 때 InstallUtil 및 net start를 사용하여 서비스를 실행하라는 메시지가 나타납니다.
다음 단계를 시도했습니다.
- 새 프로젝트 파일 만들기-> 새로 만들기-> 프로젝트-> Windows 서비스
- 프로젝트 이름 : TestService
- 있는 그대로 프로젝트 빌드 (Service1 생성자, OnStart, OnStop)
- 명령 프롬프트를 열고 "C : \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ InstallUtil.exe"TestService.exe를 실행하십시오.
- net start TestService를 실행하십시오 .
4 단계의 결과
트랜잭션 설치 실행
설치의 설치 단계 시작
C : \ Users \ myusername \ Documents \ Visual Studio 2010 \ Projects \ TestService \ TestService \ obj \ x86 \ Debug \ TestService.exe 어셈블리 진행에 대한 로그 파일 내용을 참조하십시오.
파일은 C : \ Users \ myusername \ Documents \ Visual Studio 2010 \ Projects \ Tes tService \ TestService \ obj \ x86 \ Debug \ TestService.InstallLog에 있습니다.
어셈블리 'C : \ Users \ myusername \ Documents \ Visual Studio 2010 \ Projects \ TestS ervice \ TestService \ obj \ x86 \ Debug \ TestService.exe'설치
영향을받는 매개 변수는 다음과 같습니다.
logtoconsole =
로그 파일 = C : \ Users \ myusername \ Documents \ Visual Studio 2010 \ Projects \ TestService \ T estService \ obj \ x86 \ Debug \ TestService.InstallLog
assemblypath = C : \ Users \ myusername \ Documents \ Visual Studio 2010 \ Projects \ TestServ ice \ TestService \ obj \ x86 \ Debug \ TestService.exe
C : \ Users \ myusername \ Documents \ Visual Studio 2010 \ Projects \ TestService \ TestSe rvice \ obj \ x86 \ Debug \ TestService.exe 어셈블리에서 RunInstallerAttribute.Yes 특성이있는 공용 설치 관리자를 찾을 수 없습니다.
설치 단계가 완료되었으며 커밋 단계가 시작됩니다.
C : \ Users \ myusername \ Documents \ Visual Studio 2010 \ Projects \ TestService \ TestService \ obj \ x86 \ Debug \ TestService.exe 어셈블리 진행에 대한 로그 파일 내용을 참조하십시오.
파일은 C : \ Users \ myusername \ Documents \ Visual Studio 2010 \ Projects \ Tes tService \ TestService \ obj \ x86 \ Debug \ TestService.InstallLog에 있습니다.
어셈블리 'C : \ Users \ myusername \ Documents \ Visual Studio 2010 \ Projects \ TestS ervice \ TestService \ obj \ x86 \ Debug \ TestService.exe'커밋
영향을받는 매개 변수는 다음과 같습니다.
logtoconsole =
로그 파일 = C : \ Users \ myusername \ Documents \ Visual Studio 2010 \ Projects \ TestService \ T estService \ obj \ x86 \ Debug \ TestService.InstallLog
assemblypath = C : \ Users \ myusername \ Documents \ Visual Studio 2010 \ Projects \ TestServ ice \ TestService \ obj \ x86 \ Debug \ TestService.exe
C : \ Users \ myusername \ Documents \ Visual Studio 2010 \ Projects \ TestService \ TestSe rvice \ obj \ x86 \ Debug \ TestService.exe 어셈블리에서 RunInstallerAttribute.Yes 특성이있는 공용 설치 관리자를 찾을 수 없습니다.
설치 프로그램이 없으므로 InstallState 파일을 제거하십시오.
커밋 단계가 성공적으로 완료되었습니다.
처리 된 설치가 완료되었습니다.
5 단계의 결과
서비스 이름이 유효하지 않습니다.
NET HELPMSG 2185를 입력하면 추가 도움말을 볼 수 있습니다.
디자이너에서 Service.cs 파일을 열고 마우스 오른쪽 단추로 클릭 한 다음 메뉴 옵션 "Add Installer"를 선택하십시오.
즉시 설치되지는 않습니다 ... 먼저 설치 관리자 클래스를 만들어야합니다.
서비스 설치 프로그램에 대한 일부 참조 :
아주 오래된 ...하지만 이것이 내가 말하는 것입니다 :
C #의 Windows 서비스 : 설치 관리자 추가 (3 부)
이렇게하면 a ProjectInstaller.cs
가 자동으로 생성됩니다. 그런 다음이를 두 번 클릭하고 디자이너를 입력 한 후 구성 요소를 구성하십시오.
serviceInstaller1
서비스 자체의 속성이 있습니다Description
,DisplayName
,ServiceName
그리고StartType
가장 중요하다.serviceProcessInstaller1
이 중요한 속성이 있습니다.Account
즉, 서비스가 실행될 계정입니다.
예를 들면 다음과 같습니다.
this.serviceProcessInstaller1.Account = ServiceAccount.LocalSystem;
보고 :
C : \ Users \ myusername \ Documents \ Visual Studio 2010 \ Projects \ TestService \ TestSe rvice \ obj \ x86 \ Debug \ TestService.exe 어셈블리에서 RunInstallerAttribute.Yes 특성이있는 공용 설치 관리자를 찾을 수 없습니다.
코드에 설치 관리자 클래스가없는 것 같습니다. 이것은 클래스를 상속받은 클래스로 실행 파일을 서비스로 설치하는 방법을 Installer
알려 installutil
줍니다.
P.s. I have my own little self-installing/debuggable Windows Service template here which you can copy code from or use: Debuggable, Self-Installing Windows Service
Here is an alternate way to make the installer and get rid of that error message. Also it seems that VS2015 express does not have the "Add Installer" menu item.
You simply need to create a class and add the below code and add the reference System.Configuration.Install.dll.
using System.Configuration.Install;
using System.ServiceProcess;
using System.ComponentModel;
namespace SAS
{
[RunInstaller(true)]
public class MyProjectInstaller : Installer
{
private ServiceInstaller serviceInstaller1;
private ServiceProcessInstaller processInstaller;
public MyProjectInstaller()
{
// Instantiate installer for process and service.
processInstaller = new ServiceProcessInstaller();
serviceInstaller1 = new ServiceInstaller();
// The service runs under the system account.
processInstaller.Account = ServiceAccount.LocalSystem;
// The service is started manually.
serviceInstaller1.StartType = ServiceStartMode.Manual;
// ServiceName must equal those on ServiceBase derived classes.
serviceInstaller1.ServiceName = "SAS Service";
// Add installer to collection. Order is not important if more than one service.
Installers.Add(serviceInstaller1);
Installers.Add(processInstaller);
}
}
}
Two typical problems:
- Missing the ProjectInstaller class (as @MiguelAngelo has pointed)
- The command prompt must “Run as Administrator”
Another possible problem (which I ran into):
Be sure that the ProjectInstaller
class is public
. To be honest, I am not sure how exactly I did it, but I added event handlers to ProjectInstaller.Designer.cs
, like:
this.serviceProcessInstaller1.BeforeInstall += new System.Configuration.Install.InstallEventHandler(this.serviceProcessInstaller1_BeforeInstall);
I guess during the automatical process of creating the handler function in ProjectInstaller.cs
it changed the class definition from
public class ProjectInstaller : System.Configuration.Install.Installer
to
partial class ProjectInstaller : System.Configuration.Install.Installer
replacing the public
keyword with partial
. So, in order to fix it it must be
public partial class ProjectInstaller : System.Configuration.Install.Installer
I use Visual Studio 2013 Community edition.
Stealth Change in VS 2010 and .NET 4.0 and Later
No public installers with the RunInstallerAttribute.Yes attribute could be found
There is an alias change or compiler cleanup in .NET that may reveal this little tweak for your specific case.
If you have the following code …
RunInstaller(true) // old alias
You may need to update it to
RunInstallerAttribute(true) // new property spelling
It is like an alias changed under the covers at compile time or at runtime and you will get this error behavior. The above explicit change to RunInstallerAttribute(true) fixed it in all of our install scenarios on all machines.
After you add project or service installer then check for the “old” RunInstaller(true) and change it to the new RunInstallerAttribute(true)
Yet another catch I ran into: ensure your Installer derived class (typically ProjectInstaller
) is at the top of the namespace hierarchy, I tried to use a public class within another public class, but this results in the same old error:
No public installers with the RunInstallerAttribute.Yes attribute could be found
참고URL : https://stackoverflow.com/questions/7922105/install-windows-service-created-in-visual-studio
'Programming' 카테고리의 다른 글
delete []는 그것이 배열임을 어떻게 알 수 있습니까? (0) | 2020.06.27 |
---|---|
jest.setTimeout에 의해 지정된 5000ms 시간 초과 내에 비동기 콜백이 호출되지 않았습니다. (0) | 2020.06.27 |
CSS로 전체 웹 페이지를 확장하려면 어떻게해야합니까? (0) | 2020.06.27 |
Java : 스트림의 올바른 문자 세트 인코딩을 결정하는 방법 (0) | 2020.06.27 |
개인 순수 가상 기능의 요점은 무엇입니까? (0) | 2020.06.27 |