Installing a windows service as a user fails

人走茶凉 提交于 2019-12-08 05:34:15

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/5564355/installing-a-windows-service-as-a-user-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!