服务具有零应用程序(非基础设施)的端点(Service has zero application (

2019-10-17 19:01发布

我知道一个事实,即有具有相同职务的其他问题。 我想他们的解决方案无济于事

我得到这个消息,试图用它注册后开始我的服务(Windows托管) installutil
我没有任何经验, WCF ,请耐心等待。

我的服务应用程序包括两个项目:外部材料,在那里我有我的业务接口,客户端界面,数据合同和App.config,并将内部结构,包含服务实现(这是主机,实际执行在另一个文件中完成不从我的服务接口继承,我不知道这是否是一个很好的做法或没有)。
我的app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="Internals.ExecutionService" behaviorConfiguration="Default">
        <endpoint name="TCPEndpoint" 
                  address="net.tcp://localhost:8080/ExecutionService" 
                  binding ="netTcpBinding" 
                  contract="Externals.IExecutionService"/>
        <endpoint address="mex" 
                  binding="mexTcpBinding" 
                  contract="IMetadataExhange"/>
        <host>
          <baseAddresses>
            <add baseAddress="netTcp://localhost:8080/ExecutionService"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Default">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

我的界面:

using System.ServiceModel;

namespace Externals
{
    [ServiceContract(CallbackContract = typeof(IClientCallback))]
    public interface IExecutionService
    {
        /// <summary>
        /// Executes the mainflow.py file in the provided location.
        /// </summary>
        /// <param name="path">Path to the Python file.</param>
        /// <returns>Execution status. Expected to return Passed/Failed onlt.</returns>
        [OperationContract]
        ExecutionStatus Execute(string path);

        [OperationContract]
        ExecutionStatus GetStatus();
    }
}

和实现(这是真的还没有准备好,我只是想看看我是否能得到一个客户端添加服务引用):

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, IncludeExceptionDetailInFaults = true, ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false)]
    public partial class ExecutionService : ServiceBase, IExecutionService
    {
        ServiceHost myHost;
        private IClientCallback callbackChannel;

        public ExecutionService()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            myHost = new ServiceHost(typeof(ExecutionService));
            myHost.Open();
        }
}

而空实现该接口。

完整的错误:

Service cannot be started. System.InvalidOperationException: Service 'Internals.ExecutionService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.
   at System.ServiceModel.Description.DispatcherBuilder.EnsureThereAreApplicationEndpoints(ServiceDescription description)
   at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost)
   at System.ServiceModel.ServiceHostBase.InitializeRuntime()
   at System.ServiceModel.ServiceHostBase.OnBeginOpen()
   at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open()
   at Internals.ExecutionService.OnStart(String[] args) in C:\Users...

从事件查看器拍摄。

Answer 1:

你的app.config应该是内部的,不是外部的。 其重命名为Internals.exe.config(或任何你的“内部” exe文件被命名),并把它放在同一目录下的EXE服务。



文章来源: Service has zero application (non-infrastructure) endpoints