我有一个用c#编写的自定义Windows服务,我需要安装和调试。当我使用
installutil "[path].exe"
从命令行然后尝试搜索该服务,它不会出现在任何地方的已安装服务列表中。查看安装日志文件,我看到了:
Installing assembly 'myservice'.
Affected parameters are:
logtoconsole =
assemblypath = mypath
logfile = mylogfile
Installing service MyService
Service MyService has been successfully installed.
Creating EventLog source MyService in log Application...
Committing assembly 'myservice'.
Affected parameters are:
logtoconsole =
assemblypath = myservice
logfile = pathtoinstalllog
Uninstalling assembly myservice
Affected parameters are:
logtoconsole =
assemblypath = myservice
logfile = pathtoinstalllog
Removing EventLog source myservice.
Service myservice is being removed from the system...
Service myservice was successfully removed from the system.
Uninstalling assembly myservice'.
Affected parameters are:
logtoconsole =
assemblypath = myservice
logfile = pathtoinstalllog
Removing EventLog source myservice.
Service myservice is being removed from the system...
Service myservice was successfully removed from the system.
(名称路径,myservice,pathtoinstalllog等代替公司细节)
无论如何,从日志文件看起来好像正在安装服务然后立即卸载...
如果需要更多代码或信息,请告诉我,并提前致谢。
答案 0 :(得分:2)
根据我们的讨论总结......
将“InstallUtil full-path
”用于服务主输出(bin / debug / assembly.exe)。通常如果有一个错误,InstallUtil'执行回滚'(所以注意错误) - 看起来它正在这样做但你的日志没有说 - 所以我猜你的'myservice'是错误的路径(也选择正确的InstallUtil版本,.NET框架和32/64)...
用于安全/帐户问题 - run InstallUtil elevated
('以管理员身份运行',命令提示符等) - (如果需要,请进行其他调试,尝试为您的服务帐户指定不同的用户/类型,检查安装程序类的详细信息,RunInstaller属性等)。
希望这会有所帮助