2014-02-06 58 views
8

我正在尝试创建一个基于this walkthrough的简单Windows服务。当我尝试执行命令时:无法安装简单的Windows服务 - 登录?

C:\worl\Project Alpha\Code\AlphaBackendService\AlphaBackendService\bin\Debug>ins 
tallutil.exe AlphaBackendService.exe 

它提供了一个带有用户名,密码,确认密码的对话框。我输入的东西没有工作,安装失败。它需要什么账号?为什么我不能使用我输入的任何内容?非法入境,是因为在事件日志要求的权限:

public partial class AlphaBackendService : ServiceBase 
{ 
     public AlphaBackendService() 
     { 
      InitializeComponent(); 
      if (!System.Diagnostics.EventLog.SourceExists("AlphaSource")) 
      { 
       System.Diagnostics.EventLog.CreateEventSource("AlphaSource", "AlphaLog"); 
      } 
      eventLog1.Source = "AlphaSource"; 
      eventLog1.Log = "AlphaLog"; 
     } 

     protected override void OnStart(string[] args) 
     { 
      eventLog1.WriteEntry("In OnStart"); 
     } 

     protected override void OnStop() 
     { 
      eventLog1.WriteEntry("In OnStop"); 
     } 
} 

enter image description here

+3

你是机器上的管理员吗?你可以跑高吗?如果没有,那就是你的问题 – Jason

+1

我是我的机器上的管理员,我在高架设备命令控制台中运行命令 – user2471435

+0

你是积极的吗?你能提供对话框的屏幕截图吗? – Jason

回答

20

在ProjectInstaller,该属性格式的帐户设置为本地系统(从设计师)或设置遵循的InitializeComponent代码()方法

 this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem; 
+0

“ProjectInstaller.cs”应该与项目/服务位于同一个文件夹中(添加注释,我几分钟就可以找到它):) –