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

标签 .net wcf service windows-services

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

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


enter image description here

我的配置文件代码:

<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 的代码中执行此操作。 (一个非常通用的例子):

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

关于.net - 本地计算机上的服务启动然后停止,如果其他服务或程序未使用某些服务会自动停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18670476/

相关文章:

.net - 没有完全理解ScrollViewer SnappingPoints

c# - 处理计时器的最佳方法?

wcf - 在 2012 年,MSMQ 是否仍然对 WCF 中的排队调用有效?

asp.net - 如何确定从我的 native asp.net 应用程序或 WCF 服务调用的方式

java.lang.RuntimeException : Unable to start service java. lang.NullPointerException

.net - 托管复杂的在线服务

c# - 读取和写入文件的最简单方法

c# - list clear 是否删除之前包含的对象

c# - 编写通用 WCF 服务客户端配置/端点检查器?

java安装tomcat作为服务