1

我有一个用 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.

(名称 path、myservice、pathtoinstalllog 等代替公司具体信息)

无论如何,从日志文件中看起来好像正在安装服务,然后立即卸载......

如果需要更多代码或信息,请告诉我,并提前致谢。

4

1 回答 1

2

根据我们的讨论总结...

  • use 'InstallUtil full-path' to your service main output (bin/debug/assembly.exe). Usually if there's an error InstallUtil 'performs rollback' (so watch for errors) - it looks like it's doing so but your log doesn't say - so I'm guessing your 'myservice' is of wrong path (also pick the right InstallUtil version, .NET framework and 32/64)...

  • for security/account issues - run InstallUtil elevated ('run as admin', the command prompt etc.) - (and for additional debugging if needed, try specifying different user/type for your service account, check your installer class details, RunInstaller attribute etc.).

hope this helps

于 2012-05-02T19:00:57.007 回答