When doing a WinForm project, there are two applications, host, and client deployed to the client, running a WCF service on host for client invocation. There is no problem at the time of the test, but when installing to the customer's formal environment, the service startup failure is discovered. Such as
It is obvious that this is due to the absence of administrator privileges. So does the WCF service have to be open under administrator privileges? Consulted the relevant information, found the following solutions.
Public Static classNetaclchecker { Public Static voidAddurlacltoeveryone (intPort) { stringargs =string. Format (@"http Add urlacl url=http://+:{0}/user=everyone", Port); varPSI =NewProcessStartInfo ("Netsh", args); Psi. Verb="runas"; Psi. CreateNoWindow=true; Psi. WindowStyle=Processwindowstyle.hidden; Psi. UseShellExecute=true; Process.Start (PSI). WaitForExit (); } }
class program { staticvoid Main (string[] args) { int 9090 ; Netaclchecker.addurlacltoeveryone (port); } }
Run the above program under administrator privileges, the 9090 port has been successfully added to the listening list, and then the normal user rights can be successful to open the WCF service.
How ordinary users start a WCF service