无法安装简单的Windows服务 - 登录?

use*_*435 8 c# windows-services

我正在尝试基于此演练创建一个简单的Windows服务.当我尝试执行命令时:

C:\worl\Project Alpha\Code\AlphaBackendService\AlphaBackendService\bin\Debug>ins
tallutil.exe AlphaBackendService.exe
Run Code Online (Sandbox Code Playgroud)

它会显示一个对话框,其中包含用户名,密码,确认密码.我没有输入任何内容,安装失败.它想要什么帐户?为什么我不能只使用我输入的任何内容?这是因为EventLog需要权限:

 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");
        }
 }
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

M.S*_*.S. 20

在ProjectInstaller中,将属性帐户设置为LocalSystem(来自设计器)或在InitializeComponent()方法中设置以下代码

        this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
Run Code Online (Sandbox Code Playgroud)