Why won't my Windows Service that is hosting a WCF Service run under LocalService or NetworkService accounts

◇◆丶佛笑我妖孽 提交于 2019-12-06 01:37:09

问题


I have a simple Windows Service hosting a WCF Service. I want to run the Windows Service under the LocalService account (or even the NetworkService account). However when I try to start it under either of these accounts it starts then immediately stops. It starts and runs OK under the LocalSystem account. Any thoughts as to how to work out why it will not stay running under LocalService or NetworkService.

Thanks,

David


回答1:


Thanks to the suggestions to check the event log from marc_s and ho1 I found out that I needed to add a namespace reservation as follows:

netsh http add urlacl url=http://+:1239/BOBPersistenceServer/ user="Local Service"

See http://msdn.microsoft.com/en-us/library/ms733768.aspx and http://msdn.microsoft.com/en-au/magazine/cc163531.aspx for more details.




回答2:


LocalSystem has extensive privileges on the local machine while LocalService and NetworkService have minimum privileges. So this sounds very much like your service needing some privileges that LocalService doesn't have. As marc_s says in his comment, the first step should be to check the event viewer to see if there are any relevant error messages in there.

If that doesn't help, try adding in some exception handling around the startup code in the service and log any exceptions to the Event Log, hopefully that would then give you enough information to figure out what it is that you're doing that requires higher privileges.



来源:https://stackoverflow.com/questions/3682287/why-wont-my-windows-service-that-is-hosting-a-wcf-service-run-under-localservic

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