WCF服务启动错误-服务没有应用程序端点



我正在尝试启动windows服务,我得到以下错误:

服务无法启动。系统。InvalidOperationException:服务"LazyPCAndroiderSvc。"LazyPCController"没有任何应用(non-infrastructure)端点。这可能是因为没有配置为您的应用程序找到文件,或者因为没有服务元素可以在配置文件中找到匹配的服务名称,或者因为service元素中没有定义端点。

?

我已经使用WCF Tester测试了该服务,没有出现任何问题。只有当我尝试将其作为windows服务运行时,才会导致上述错误。

下面是wcf服务中我的app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <!-- This section is optional with the new configuration model
           introduced in .NET Framework 4. -->
      <service name="LazyPCAndroiderSvc.LazyPCController"
               behaviorConfiguration="LazyPCControllerBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8750/LazyPCAndroiderSvc/LazyPCController/"/>
          </baseAddresses>
        </host>
        <endpoint address=""
                  binding="wsHttpBinding"
                  contract="LazyPCAndroiderSvc.ILazyPCController" />
        <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="LazyPCControllerBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

我已经验证了名称完全匹配(包括名称空间)。

这是我的WindowsService代码:
namespace LazyPCAndroiderWinSvc
{
    public partial class Service : ServiceBase
    {
        ServiceHost sHost;
        public Service()
        {
            InitializeComponent();
        }
        protected override void OnStart(string[] args)
        {
            sHost = new ServiceHost(typeof(LazyPCAndroiderSvc.LazyPCController));
            sHost.Open();
        }
        protected override void OnStop()
        {
            sHost.Close();
        }
    }
}

这似乎是一个微不足道的问题,但我找不到原因。

服务可能不会自动从LazyPCAndroiderSvc.dll.config读取-将这些配置放在主exe的App.config

最新更新