1

我正在使用 .Net 框架 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(无法访问 Internet):在 <URI> 处没有可以接受消息的端点侦听。这通常是由不正确的地址或 SOAP 操作引起的

因此,我尝试切换回将服务安装为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谁是管理员组的成员?

4

1 回答 1

1

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

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

于 2011-04-06T10:59:56.370 回答