gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 18:08:17 25 4
gpt4 key购买 nike

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

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

它会显示一个对话框,其中包含用户名、密码、确认密码。我输入的任何内容都不起作用,安装失败。它要什么帐号?为什么我不能只使用我输入的任何内容?是不是因为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");
}
}

enter image description here

最佳答案

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

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

关于c# - 无法安装简单 Windows 服务 - 登录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21609416/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com