VC# Service 无法启动

来源:互联网 发布:淘宝贝幼儿园电话 编辑:程序博客网 时间:2024/05/19 12:25

VC# Service (2008/08/16)

 

用 Vc#2005 安装帮助文档的步骤编写 Windows Service时,安装成功,但无法启动,Event Log 记录如下:

事件类型: 错误
事件来源: WindowsService1
事件种类: 无
事件 ID: 0
日期:  2008-8-18
事件:  8:31:32
用户:  N/A
计算机: BFF21965615E4FA
描述:
无法启动服务。System.Security.SecurityException: 未找到源,但未能搜索某些或全部事件日志。不可访问的日志: Security。
   在 System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly)
   在 System.Diagnostics.EventLog.SourceExists(String source, String machineName)
   在 System.Diagnostics.EventLog.VerifyAndCreateSource(String sourceName, String currentMachineName)
   在 System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
   在 System.Diagnostics.EventLog.WriteEntry(String message)
   在 WindowsService1.WindowsService1.OnStart(String[] args)
   在 System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)
失败的程序集的区域是:
MyComputer

 

解决方法(通过小苏帮助):

serviceProcessInstaller1 中有一个account属性,如果需要访问权限高的, 最好设置成LocalSystem,
因为程序现在是用LocalService,可能不用访问系统日志

直接在windows服务管理 双击那个程序,在“登录”中改成“本地系统帐户”,它就能启动了