以用户身份安装Windows服务失败

时间:2011-04-06 09:42:19

标签: c# windows-services installation installutil

我正在使用.Net framework 3.5版开发Windows服务。它需要在远程计算机上调用Web服务,我遇到了一个奇怪的安装问题。

我曾经以User(默认设置)在我的机器上安装它,并在提示时提供了我的登录名和密码,一切正常。然后在某个时候,它停止了工作,我发现将其安装为LocalSystem并且工作正常。

现在我正在尝试调用远程Web服务,我从WCF收到错误:

There was no endpoint listening at https://www.remote.com/webservice.asmx that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

显然,这可能是因为LocalSystem(无法访问互联网)运行服务:There was no endpoint listening at <URI> that could accept the message. This is often caused by an incorrect address or SOAP action

所以,我已经尝试切换回安装服务User并提供我的凭据(此时我应该注意我是我的机器的管理员)。但它不起作用,并且错误消息(以及InstallUtil日志文件的内容)接下来是无用的:

Running a transacted installation.

Beginning the Install phase of the installation.
See the contents of the log file for the Service.exe assembly's progress.
The file is located at Service.InstallLog.

An exception occurred during the Install phase.
System.InvalidOperationException: An exception occurred in the OnAfterInstall event handler of System.ServiceProcess.ServiceInstaller.
The inner exception System.InvalidOperationException was thrown with the following error message: Service ServiceName was not found on computer '.'.
The inner exception System.ComponentModel.Win32Exception was thrown with the following error message: The specified service does not exist as an installed service.

The Rollback phase of the installation is beginning.
See the contents of the log file for the Service.exe assembly's progress.
The file is located at Service.InstallLog.

The Rollback phase completed successfully.

The transacted install has completed.

据我所知,相关的一点是该服务无法安装。没有更多信息!有关服务可能以LocalSystem成功安装但在安装为管理员组成员User时失败的任何想法吗?

1 个答案:

答案 0 :(得分:1)

试试NetworkService用户。 出于安全原因,不允许LocalService与外界建立连接。

至于您无法自行安装服务的原因,这可能是由UAC引起的。我发现除非UAC完全关闭,否则安装服务是不可能的,即使您是帐户的管理员也是如此。这是因为您的帐户没有此特权。我相信您可以通过组策略管理器解决此问题。