C# 安装.Net开发的Windows服务时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2205744/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error in installing Windows service developed in .Net
提问by Sambha
I have developed a windows service using C#,visual studio 2008. I have windows xp sp2 installed on my machine. When I try to install the service using installutil tool, after entering the username and password, I get following error.
我使用 C#,visual studio 2008 开发了一个 windows 服务。我的机器上安装了 windows xp sp2。当我尝试使用 installutil 工具安装服务时,输入用户名和密码后,出现以下错误。
An exception occurred during the Install phase. System.ComponentModel.Win32Exception: The account name is invalid or does not exist, or the password is invalid for the account name specified.
安装阶段发生异常。System.ComponentModel.Win32Exception: 帐户名无效或不存在,或者指定帐户名的密码无效。
But the user does exist. I had created the user through control panel->user accounts->create new account. The command I used for installing the service is installutil /i TestService.exe
但用户确实存在。我通过控制面板-> 用户帐户-> 创建新帐户创建了用户。我用于安装服务的命令是 installutil /i TestService.exe
I am unable to resolve the issue.
我无法解决这个问题。
Thanks in Advance
提前致谢
Sambha
桑巴
采纳答案by Oded
If the account is a local user account, try to use .\username
when installutil prompts for the username and password.
如果帐户是本地用户帐户,请尝试.\username
在 installutil 提示输入用户名和密码时使用。
The .\
stands for local machine.
该.\
代表本地机器。
Services require a fully qualified username (with domain), so when installing you need to be explicit about local user accounts.
服务需要一个完全限定的用户名(带域),所以在安装时你需要明确本地用户帐户。
回答by devstuff
The account may also need to be given the "Log on as a service" account right; pass the SE_SERVICE_LOGON_NAME
constant to the LsaAddAccountRights()
API.
该帐户可能还需要被赋予“作为服务登录”的帐户权限;将SE_SERVICE_LOGON_NAME
常量传递给LsaAddAccountRights()
API。
回答by Deepp
I solved this by changing ServiceProcessInstaller.Account to LocalSystem. and its works for me.
我通过将 ServiceProcessInstaller.Account 更改为 LocalSystem 解决了这个问题。它对我有用。