5

我创建了一个示例 Windows 服务并成功安装了我的服务。但是在启动服务的同时。我得到以下错误。

本地计算机上的此服务启动然后停止。如果某些服务没有被其他服务或程序使用,则某些服务会自动停止

在此处输入图像描述

我的配置文件代码:

<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>

任何人都可以请建议我...谢谢您的建议。

4

1 回答 1

3

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"));
于 2013-09-07T07:19:33.277 回答