.net 本地计算机上的服务启动后停止,如果其他服务或程序未使用某些服务,则某些服务将自动停止

.net 本地计算机上的服务启动后停止,如果其他服务或程序未使用某些服务,则某些服务将自动停止,.net,wcf,service,windows-services,.net,Wcf,Service,Windows Services,我创建了一个示例windows服务,并使用成功安装了我的服务。但是在开始服务的时候。我正在犯错误 本地计算机上的此服务启动后停止。 如果其他服务或程序不使用某些服务,则某些服务将自动停止 我的配置文件代码: <system.serviceModel> <services> <service name="SvcClient.WCFJobsLibrary.Service1"> <endpoint address="" b

我创建了一个示例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>

谁能建议我。。。
感谢您的支持。

您需要指定服务的端点(客户端可以访问服务的URI)

您可以在实例化
ServiceHost
的代码中执行此操作(一个非常通用的示例):


在事件查看器中查看windows应用程序日志,查看您的服务是否有任何错误。谢谢您的建议。当我转到EventViewer中的应用程序日志时。我有一个错误,如:“服务无法启动。System.InvalidOperationException:服务'MyService'没有应用程序(非基础设施)端点。这可能是因为找不到应用程序的配置文件,或者是因为在配置文件中找不到与服务名称匹配的服务元素,或者是因为在服务元素中未定义端点。“为此,我更新了配置,如下所示:到
ServiceHost myHost = new ServiceHost(typeof(TechResponse), new Uri("http://www.somedomain.com/TechResponse"));