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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18670476/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 12:26:34  来源:igfitidea点击:

The Service on local computer started and then stopped ,Some services stop automatically if there are not in use by other services or programs

.netwcfservicewindows-services

提问by Jagadeesh

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

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

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.

任何人都可以请建议我...感谢广告。

采纳答案by Tim

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

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

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

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

ServiceHost myHost = new ServiceHost(typeof(TechResponse), new Uri("http://www.somedomain.com/TechResponse"));