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

发布于 2024-10-30 20:24:38 字数 1954 浏览 1 评论 0原文

我正在使用 .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 运行(无法访问互联网)所致: 有没有端点监听在处可以接受该消息。这通常是由不正确的地址或 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 安装时失败?

I'm developing a windows service using .Net framework version 3.5. It needs to call a web service on a remote machine and I'm running into a weird installation problem.

I used to install it on my machine as User (the default), and when prompted provided my login and password and everything worked fine. Then at some point, it stopped working, and I found out about installing it as LocalSystem and that worked fine.

Now I'm trying to call the remote web service and I'm getting an error from 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.

Apparently, this could be due to running the service as LocalSystem (which doesn't have internet access) : There was no endpoint listening at <URI> that could accept the message. This is often caused by an incorrect address or SOAP action

So, I've tried to switch back to installing the service as User and providing my credentials (I should note at this point that I'm an administrator of my machine). But it doesn't work, and the error message (and the contents of the InstallUtil log file) are next to useless:

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.

As far as I can tell the relevant bit is that the service failed to install. No more information! Any ideas why a service might install successfully as LocalSystem but fail when installing as User who is a member of the Administrators group?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

盛夏已如深秋| 2024-11-06 20:24:38

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

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

Try the NetworkService user.
LocalService is not allowed to have connections to the outside world for security reasons.

As for the reason you can't install the service as yourself, this might be due to UAC. I have found that installing services is impossible unless UAC is completely turned off, even if you are Administrator of your account. This is because your account does not have this special privilege. I believe you can fix this through the Group Policy Manager.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文