locked
Problem in hosting a WCF service by Windows Service RRS feed

  • Question

  • User-83126419 posted

    Hi,

    I have created a simple wcf service. I have already debug the wcf service separately, it's okay then. I have hosted it by a windows service. But when I install the windows service in my computer and tried to start the windows service, it can't be start. It's getting the following exception.

    Service cannot be started. System.ServiceModel.AddressAccessDeniedException: HTTP could not register URL http://+:8080/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details). ---> System.Net.HttpListenerException: Access is denied
    at System.Net.HttpListener.AddAllPrefixes()
    at System.Net.HttpListener.Start()
    at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
    --- End of inner exception stack trace ---
    at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
    at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
    at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
    at System.ServiceModel.Channels.TransportChannelListener.OnOpen(TimeSpan timeout)
    at System.ServiceModel.Channels.HttpChannelListener`1.OnOpen(TimeSpan timeout)
    at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan ...



    Although I have started my visual studio as an administrator and also the visual studio developer command window during the service installation. I have also register the base address of the service by using the command "netsh http add urlacl url=http://+:8080/MyUri user=DOMAIN\user". None of those process can't solve the exception. Please suggest me a way to solve the exception.

    Saturday, September 16, 2017 4:49 PM

Answers

  • User1168443798 posted

    Hi rayhan,

    >> But when I install the windows service in my computer and tried to start the windows service, it can't be start.

    Which account did you use in Service Installer Properties pane?

    I suggest you check whether you run windows service under “DOMAIN\user”.

    Best Regards,

    Edward

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 18, 2017 2:19 AM

All replies

  • User1120430333 posted


     Although I have started my visual studio as an administrator

    How did you do that?  If you didn't set the VS short-cut to 'run as administrator'  and got the UAC prompt, then VS is not running with admin rights.

    I would say that the Windows service in not using an user account that has admin rights and/or Windows service is not using a UAC manifest that specifies run wit admin rights.  

    Sunday, September 17, 2017 10:38 PM
  • User1168443798 posted

    Hi rayhan,

    >> But when I install the windows service in my computer and tried to start the windows service, it can't be start.

    Which account did you use in Service Installer Properties pane?

    I suggest you check whether you run windows service under “DOMAIN\user”.

    Best Regards,

    Edward

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 18, 2017 2:19 AM
  • User-83126419 posted

    I have already started the VS 'run as administrator' from the VS short-cut and the VS is running with admin rights. Beside this also added an Application Manifest File in the peoject and force the application to run with admin previllage but don't overcome the problem yet.

    Monday, September 18, 2017 10:32 AM
  • User-83126419 posted

    I have used LocalSystem account in ServiceProcessInstaller properties pane and also my windows service is running under "DOMAIN\user".

    Monday, September 18, 2017 10:39 AM
  • User1168443798 posted

    Hi rayhan,

    Could you share us your demo project solution and detail steps to produce your issue? We will try to reproduce your issue based on provided information.

    I suggest you run below command to check whether netsh add url correctly.

    netsh http show urlacl

    Best Regards,

    Edward

    Tuesday, September 19, 2017 8:23 AM
  • User-83126419 posted

    Thanks Edward. The issue is solved. There was a mismatch of account between ServiceProcessInstaller and where the windows service was running.

    Tuesday, September 19, 2017 9:18 AM