6

I created one sample windows service and installed my service with successfully. But while going to START the service. I am getting below error.

This sevice on local computer started and then stopped. some serivces stop automatically if then are not in use by other serives or programs

enter image description here

My config file Code:

<system.serviceModel>
    <services>
      <service name="SvcClient.WCFJobsLibrary.Service1">
        <endpoint address="" binding="wsHttpBinding" contract="WCFJobsLibrary.IService1">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/Design_Time_Addresses/WCFJobsLibrary/Service1/" />
          </baseAddresses>
        </host>
      </service>
 </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

Can any one please suggest me... Thanks in adv.

Jagadeesh
  • 1,630
  • 8
  • 24
  • 35
  • 7
    Take a look at the windows application log in the Event Viewer to see if there are any errors from your service. – Tim Sep 07 '13 at 06:28
  • 2
    Thanks for ur suggestion. when i went to application logs in EventViewer. I have an error like: "Service cannot be started. System.InvalidOperationException: Service 'MyService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element." – Jagadeesh Sep 07 '13 at 07:08
  • For this I have updated my config like this: to – Jagadeesh Sep 07 '13 at 07:10

1 Answers1

4

You need to specify the endpoint of the service (the URI at which the service can be reached by the client).

You can do it in the code where you instantiate the ServiceHost (a very generic example):

ServiceHost myHost = new ServiceHost(typeof(TechResponse), new Uri("http://www.somedomain.com/TechResponse"));
Tim
  • 28,212
  • 8
  • 63
  • 76