none
WCF winthin Windows Service - Cant start service. Error: The communication object, System.ServiceModel.ServiceHost, cannot be used for communication because it is in the Faulted state. RRS feed

  • Question

  • Hi,

    I'm trying to start open a WCF connection within Windows Service as below, but for unknown reason I'm getting the error message "Cant start service. Error: The communication object, System.ServiceModel.ServiceHost, cannot be used for communication because it is in the Faulted state.":

    protected override void OnStart(string[] args)
            {
                try
                {
                    var serviceUri = string.Format("http://{0}:12345/APSService", Dns.GetHostName());
                    using (var host = new ServiceHost(typeof(APSService), new Uri(serviceUri)))
                    {
                        host.Open();
    
                        eventLog1.WriteEntry("Service is running...");
                    }
                }
                catch (Exception ex)
                {
                    eventLog1.WriteEntry("Cant start service. Error: " + ex.Message);
                }
            }

    Can you please help me solve this issue?

    Regards,

    Bader

    Sunday, March 31, 2013 11:52 AM

Answers

  • Hi,

    First of all, please make sure you have run the application at administrator. Then follow below steps.

      • Build the solution to create the Service.exe executable.
      • Open the Visual Studio 2012 command prompt and navigate to the project directory. Type installutil bin\service.exe at the command prompt to install the Windows service.

    • After install the service, please make sure the service is running(find the service by typing services.msc at the command prompt to access the Service Control Manager (SCM)).

    Download the sample from #Windows Service Host

    http://msdn.microsoft.com/en-us/library/vstudio/ms751414(v=vs.100).aspx

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, April 2, 2013 6:45 AM
    Moderator

All replies