1

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?

Community
  • 1
  • 1
Jackson Pope
  • 14,520
  • 6
  • 56
  • 80

1 Answers1

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.

Jonas Van der Aa
  • 1,441
  • 12
  • 27
  • Trying to install as NetworkService throws a Win32Exception in OnAfterInstall with message: Access is denied. – Jackson Pope Apr 06 '11 at 11:13
  • I should clarify: I meant _run_ the service as NetworkService user. You need to install it as a user with special privileges. Is UAC active on this machine? – Jonas Van der Aa Apr 06 '11 at 11:21
  • @Jonas: Yes, it's a Windows 7 box, so I think UAC is being used. I'm running InstallUtil in a Visual Studio Command Prompt (which I opened with 'Run as Administrator'). My earlier comment (installed as NetworkService) is not quite right, what I mean is that the Account property of the ServiceProcessInstaller (i.e. the account it will run as) is set to NetworkService. It's also worth noting it is set to start automatically (though I get the same problems when I set it to start manually). – Jackson Pope Apr 06 '11 at 11:34
  • Can dig through the Event Logs to see if you can find something more specific on the Win32Exception? Even if you're an Admin UAC will block you off sometimes. – Jonas Van der Aa Apr 06 '11 at 11:43
  • And make sure the NetworkService account has execution privileges on the EXE. – Jonas Van der Aa Apr 06 '11 at 11:49
  • @Jonas: I've got the install to work for NetworkService (by giving NetworkService rights to the service directory), but the WCF call still fails *shakes*. Anyway - you've solved the problem in the question - thanks for your help. – Jackson Pope Apr 06 '11 at 11:49